https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64309
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> --- (In reply to Oleg Endo from comment #7) > (In reply to Marek Polacek from comment #5) > > > > I don't think so. I tried to come up with a more general transformation > > that would simplify ((CST << n) & CST) != 0, but I haven't found anything > > yet. So maybe just this? > > ((1 << n) & 1) != 0 -> n == 0 > > ((1 << n) & 1) == 0 -> n != 0 > > If I'm not mistaken... > > (1 << n) & 2 != 0 -> n == 1 > (1 << n) & 3 != 0 -> n < 2 (unsigned) > (1 << n) & 4 != 0 -> n == 2 > (1 << n) & 5 != 0 -> n == 0 || n == 2 (not beneficial) > (1 << n) & 6 != 0 -> n > 0 && n < 3 (not beneficial) > (1 << n) & 7 != 0 -> n < 3 (unsigned) > ... Right - but to me only the first one seems like a win.