[Bug tree-optimization/91965] missing simplification for (C - a) << N
amonakov at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Oct 2 18:33:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91965
--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #2)
> What exact transformation do you want? Canonicalize the constant C to
> something like C % (1 << (bitsize - N))?
I'm thinking (C << N) >>> N where '>>>' is sign-extending right shift. In other
words, duplicate the bit at position (bitsize - 1 - N) to the left. In the
opening example, I want to go from
(0xfffff - a) << 44
to
(-1 - a) << 44
> For unsigned only... didn't we use to canonicalize in the reverse direction,
> i.e. from x*4 to x<<2?
For unsigned - because we promise not to use undefined overflow for signed left
shifts? Can we canonicalize to a wrapping multiplication?
More information about the Gcc-bugs
mailing list