https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64309
--- Comment #4 from Oleg Endo <olegendo at gcc dot gnu.org> --- (In reply to Richard Biener from comment #1) > Confirmed. Sth like > > (simplify > (ne (bit_and (lshift integer_onep @0) integer_onep) integer_zerop) > (eq @0 { build_zero_cst (TREE_TYPE (@0)); }) > > with eventually also covering if ((1 & (1<< n)) == 0) -> if (n & 1 == 0) > > You can extend this to cover the other cases you mention. I thought you might suggest something like this. :) While the transform for the if (...) is probably going to be beneficial for all the targets, I'm not so sure about the 'return ((1 << 1) & (1 << n));' variant, though. On some targets a shift+and might be cheaper than cmp+cstore. Is there any way to get that information during tree optimization? If not, it might be better to do that transformation on the RTL.