RISC-V: Add zero_extract support for rv64gc
commit3b9c760072c7792cbae6f38894756d2b96c2fd8c
authorChristoph Müllner <christoph.muellner@vrull.eu>
Mon, 6 May 2024 10:33:32 +0000 (6 12:33 +0200)
committerChristoph Müllner <christoph.muellner@vrull.eu>
Wed, 8 May 2024 14:09:27 +0000 (8 16:09 +0200)
tree72ec3e5cec17d52531c27540e313088280e3dfef
parent4e46a3537ff57938a0d98fa524ac2fff8b08ae6d
RISC-V: Add zero_extract support for rv64gc

The combiner attempts to optimize a zero-extension of a logical right shift
using zero_extract. We already utilize this optimization for those cases
that result in a single instructions.  Let's add a insn_and_split
pattern that also matches the generic case, where we can emit an
optimized sequence of a slli/srli.

Tested with SPEC CPU 2017 (rv64gc).

PR target/111501

gcc/ChangeLog:

* config/riscv/riscv.md (*lshr<GPR:mode>3_zero_extend_4): New
pattern for zero-extraction.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/extend-shift-helpers.h: New test.
* gcc.target/riscv/pr111501.c: New test.
* gcc.target/riscv/zero-extend-rshift-32.c: New test.
* gcc.target/riscv/zero-extend-rshift-64.c: New test.
* gcc.target/riscv/zero-extend-rshift.c: New test.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
gcc/config/riscv/riscv.md
gcc/testsuite/gcc.target/riscv/extend-shift-helpers.h [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/pr111501.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zero-extend-rshift-32.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zero-extend-rshift-64.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/zero-extend-rshift.c [new file with mode: 0644]