On Sat, Aug 8, 2026 at 5:24 PM Roger Sayle <[email protected]> wrote:
>
>
> My recent patch to improve bitreverse support on cris, posted at
> https://gcc.gnu.org/pipermail/gcc-patches/2026-August/726384.html
> revealed an optimization opportunity.  If you look closely GCC's
> expansion of bitreverse (in optabs.cc) generates a left shift
> followed by an IOR in several places.  In these instances, its
> possible to use "any_or_plus", and in fact using PLUS would allow
> cris to use its addi instruction, and the x86 to use its lea
> instruction.  I believe PLUS is always as efficient as IOR for
> SImode/wordmode, even on processors that have to use add with carry,
> i.e. addc[qh]i3.  For other (longer) modes (such as vector modes),
> it's better to use IOR, and for shorter modes I'm not sure there's
> any advantage to using PLUS.  If I'm wrong for some targets, we
> can make aop_optab a real optab.

Please note PR108477 [1] where fwprop conversion from '+' to '|' can
interfere with your proposed optimization and the discussion about a
patch that would generate LEA some more, started from [2].

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108477
[2] https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642164.html

Uros.

Reply via email to