RISC-V: Fine tune RA constraint for narrow instructions
authorJu-Zhe Zhong <juzhe.zhong@rivai.ai>
Fri, 10 Mar 2023 03:02:05 +0000 (11:02 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 13 Mar 2023 16:25:10 +0000 (00:25 +0800)
commit7ff57009bcc728044ba2de339ecd16721d48aba3
tree80440de803912b430a8353eb69e2a9950bd055dc
parentced122b849b8961b854053f0d1ac96983c5802e5
RISC-V: Fine tune RA constraint for narrow instructions

According to RVV ISA, for narrow instructions:

The destination EEW is smaller than the source EEW and the overlap is
in the lowest-numbered part of the source register group.
(e.g., when LMUL=1, vnsrl.wi v0, v0, 3 is legal, but a destination of v1 is not).

We should allow narrow instructions partially overlap base on the rule of RVV ISA above
so that we could exploit the useage of vector registers.

Consider these cases:
https://godbolt.org/z/o6sc4eqGj

some cases in LLVM have redundant move instructions,
some cases in LLVM have redundant register spillings.

Now after this patch, GCC can have perfect RA && codegen for different pressure RA cases.

gcc/ChangeLog:

* config/riscv/vector.md: Fine tune RA constraints.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/narrow_constraint-1.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-10.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-11.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-2.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-3.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-4.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-5.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-6.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-7.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-8.c: New test.
* gcc.target/riscv/rvv/base/narrow_constraint-9.c: New test.
12 files changed:
gcc/config/riscv/vector.md
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-10.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-11.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/narrow_constraint-9.c [new file with mode: 0644]