Re: [PATCH 1/1] forwprop: Extend memcmp forwprop inlining to the general case

Tudor-Stefan Magirescu <[email protected]> Wed, 5 Aug 2026 10:36:58 +0200
Newsgroups gmane.comp.gcc.patches
Message-ID <CABSDnQ6xPaCL5y+rQsWtTukuHS5nSCA8h5OJoa+xYRBSbhdyOg@mail.gmail.com>
On Sun, Aug 2, 2026 at 11:01=E2=80=AFAM Andrea Pinski
<[email protected]> wrote:
>
> Instead of adding a new target hook. I think it is just better to look
> to see if there is byteswap optab for that mode.
> That is just `can_open_code_p (bswap_optab, mode)`.
> This should simplify the code here too.
>
> Thanks,
> Andrea
>

My current implementation uses both `can_open_code_p` and the hook.
My understanding is that the obtab's existence for a given mode does
not guarantee an efficient implementation.  For example, on x86,
bwapsi2 is a `define_expand` pattern that may fall back to a
multi-instruction sequence when TARGET_BSWAP is not set.
Similarly, on pre-ARMv6, bswapsi2 expands to an instruction sequence
rather than a single REV instruction.  In both cases can_open_code_p
would return true, but the optimization may not be profitable.

I may be misunderstanding how `can_open_code_p` works in this context
though.  If it already handles these cases correctly, I am happy to
drop the hook and simplify accordingly.

Tudor