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

--- Comment #4 from Daniel Henrique Barboza <daniel.barboza at oss dot 
qualcomm.com> ---
I'm testing a match.pd pattern that implements this optimization, but being
match.pd it will affect gimple and all targets.  If we want a solution that
takes RTX costs into consideration we'll need a target-specific solution (i.e.
I will do it for risc-v only), which I'm fine with.

All this said, the proposed optimization is a lshift with a shamt being changed
for a bit_and with a shamt len mask, so:

(1) a << 1 == C -> a & 0x1 == ...
(2) a << 4 == C -> a & 0xf == ...
(3) a << 63 == C -> a & 0xffffffffffffffff == ...

>From what I can say the optimization will always be faster for (3) and other
large values of shamt.  Is there a target that would lose performance in case
of (1)?

Reply via email to