https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116355
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- gen_pow2p is where the issue is. So there is a few ways of fixing this I think. One is to convert to an unsigned type if not already. But there is another way is to use __builtin_popcount{,l,ll} always and let other passes optimize it into what the target wants. Because `POPCOUNT(a) == 1` is not the same as `a & -a == a` either but rather: int f(int a) { int b = a - 1; return (unsigned)(b ^ a) > (unsigned)a; } You can see that with aarch64 code generation even: cipher_to_alg: sub w1, w0, #1 eor w2, w0, w1 cmp w2, w1 bls .L3