On 11/17/26 10:35 PM, Jiawei wrote:
Keep the five- or six-bit mask when rewriting a shift count as a
complement. Dropping it can produce wrong code when combine later
selects an XLEN-wide Zbs instruction for a word mask.

Preserve the masks in both the native and word splitters. Existing
masked shift patterns still emit the same instructions. Add a runtime
test for narrow counts derived from 31 - y and check that PR123838
still needs no separate masking instruction.

gcc/ChangeLog:

        * config/riscv/riscv.md: Preserve count masks in the native and
        word shift-complement splitters.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/pr123838.c: Check for no extra andi.
        * gcc.target/riscv/shift-count-complement-1.c: New test.
Ah!  Good solution routing the split RTL into a pre-existing pattern with sanitization of the count to keep the RTL consistent.

LGTM, sashiko clean.  OK for the trunk.

Thanks,
Jeff


Reply via email to