]> git.ipfire.org Git - thirdparty/gcc.git/commit
[RISC-V] shift+and+shift for logical and synthesis
authorShreya Munnangi <smunnangi1@ventanamicro.com>
Sat, 24 May 2025 19:52:55 +0000 (13:52 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Sat, 24 May 2025 19:55:12 +0000 (13:55 -0600)
commit2e2557d160cc0b893a7bcad1bee1683ad948dc60
tree70e5bac616f86faa4f2c24f181c539447a5050bb
parent9c83e15f092a9e6bffcf9e34213accce35989220
[RISC-V] shift+and+shift for logical and synthesis

The next chunk of Shreya's work.

For this expansion we want to detect cases when the mask fits in a simm12 after
shifting right by the number of trailing zeros in the mask.

In that case we can synthesize the AND with a shift right, andi and shift left.
I saw this case come up when doing some experimentation with mvconst_internal
removed.

This doesn't make any difference in spec right now, mvconst_internal will turn
the sequence back into a constant load + and with register. But Shreya and I
have reviewed the .expand dump on hand written tests and verified we're getting
the synthesis we want.

Tested on riscv32-elf and riscv64-elf.  Waiting on upstream CI's verdict before
moving forward.

gcc/
* config/riscv/riscv.cc (synthesize_and): Use a srl+andi+sll
sequence when the mask fits in a simm12 after shifting by the
number of trailing zeros.

Co-authored-by: Jeff Law <jlaw@ventanamicro.com>
gcc/config/riscv/riscv.cc