https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124019
Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hp at gcc dot gnu.org
--- Comment #3 from Hans-Peter Nilsson <hp at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Confirmed.
>
> I think we should just have `(a << CST0) == CST1` as being Canonicalize to
> `(a&CSTmask) == (CST1>>CST0)` on the gimple level. Shift is always always
> expensive than BIT_AND.
No no no. Not another "all targets are X" statement, please A shift plus a
small constant operand to AND is sometimes cheaper than AND with a large
constant, both for speed and size. I did a minor micro-optimization run for
CRIS some time ago tweaking stuff that got suboptimal with LRA.
I agree some optimization seems to be called for here, but whatever
optimization pattern is done here, please include a RTX costs condition for the
exact operands (and be aware that insn_costs is very flawed).