https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64309

--- Comment #11 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #7)
> (1 << n) & 6 != 0 -> n > 0 && n < 3 (not beneficial)

We usually spell it (unsigned)n-1<2 (still not that great).

(In reply to Marek Polacek from comment #8)
> > > 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
> > 
> > If both CST are (possibly different) powers of 2 it works.
> 
> Yes, but I'm not sure if it's worth it (doing it for 1, 2, 4, 8, ... instead
> of just for 1).

I am not sure why 1 is so much more important than the others...

> > ((c<<n)&c)==c also works. ((pow2<<p)&(pow2<<n))!=0.
> 
> I don't see how's that a simplification.

((c<<n)&c)==c -> n==0
((pow2<<p)&(pow2<<n))!=0 -> p==n

Reply via email to