https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107053
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note the correct testcase is: void link_failure(); void f(int a) { a |= 0x300; int b = __builtin_popcount(a); if (b < 2) link_failure(); } --- CUT --- the range of b should be 2..31 (assuming int is 32bits). With this change clang is able to optimize it. For the original testcase I think it can be folded to: void link_failure(); void f(int a) { int a1 &= ~0x300; if (a1 != 0) link_failure(); } but that might be worse unless popcount can be removed. (If I did this correctly).