https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89670
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- int foo (int x) { return x ? __builtin_ctz (x) : 32; } works without conditionals just fine for me, both in 8.x and trunk, both C and C++, both -O2 and -O3.