]> git.ipfire.org Git - thirdparty/gcc.git/commit
[to-be-committed][RISC-V] Reassociate constants in logical ops
authorLyut Nersisyan <lyut.nersisyan@gmail.com>
Mon, 27 May 2024 03:24:40 +0000 (21:24 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 27 May 2024 03:25:31 +0000 (21:25 -0600)
commit160929406f0c44df5b0d377a014ebfe5027fe4e7
tree6b7e75ad9d57c3439457c8d55df030f0e19916e0
parent0022064649d0ec40e97df24279c48842e278fedc
[to-be-committed][RISC-V] Reassociate constants in logical ops

This patch from Lyut will reassociate operands when we have shifted logical
operations.  This can simplify a constant that may not be fit in a simm12 into
a form that does fit into a simm12.

The basic work was done by Lyut.  I generalized it to handle XOR/OR.

It stands on its own, but also helps the upcoming Zbkb work from Lyut.

This has survived Ventana's CI system as well as my tester.  Obviously I'll
wait for a verdict from the Rivos CI system before moving forward.

gcc/

* config/riscv/riscv.md (<optab>_shift_reverse<X:mode>): New pattern.

gcc/testsuite

* gcc.target/riscv/and-shift32.c: New test.
* gcc.target/riscv/and-shift64.c: New test.

Co-authored-by: Jeffrey A Law <jlaw@ventanamicro.com>
gcc/config/riscv/riscv.md
gcc/testsuite/gcc.target/riscv/and-shift32.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/and-shift64.c [new file with mode: 0644]