RISC-V: Fix LRA issue for LMUL < 1 vector spillings [PR109244]
authorJu-Zhe Zhong <juzhe.zhong@rivai.ai>
Wed, 22 Mar 2023 02:49:56 +0000 (10:49 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 23 Mar 2023 03:14:12 +0000 (11:14 +0800)
commitcd0c433e5faba9a18f64881cd761a53a530aa798
treeb780f5a6bd08e01de13c3d9b96c7e6cad1f9b679
parent116a8678840f9f52ec14639ff07e302a8c429f32
RISC-V: Fix LRA issue for LMUL < 1 vector spillings [PR109244]

In order to decrease the memory traffic, we don't use whole register
load/store for the LMUL less than 1 and mask mode, so those case will
require one extra general purpose register for setting up VL register,
but it's not allowed during LRA process, so we defined few special move patterns
used for LRA, which will defer the expansion after LRA.

gcc/ChangeLog:

PR target/109244
* config/riscv/riscv-protos.h (emit_vlmax_vsetvl): Define as global.
(emit_vlmax_op): Ditto.
* config/riscv/riscv-v.cc (get_sew): New function.
(emit_vlmax_vsetvl): Adapt function.
(emit_pred_op): Ditto.
(emit_vlmax_op): Ditto.
(emit_nonvlmax_op): Ditto.
(legitimize_move): Fix LRA ICE.
(gen_no_side_effects_vsetvl_rtx): Adapt function.
* config/riscv/vector.md (@mov<V_FRACT:mode><P:mode>_lra): New pattern.
(@mov<VB:mode><P:mode>_lra): Ditto.
(*mov<V_FRACT:mode><P:mode>_lra): Ditto.
(*mov<VB:mode><P:mode>_lra): Ditto.

gcc/testsuite/ChangeLog:

PR target/109244
* g++.target/riscv/rvv/base/pr109244.C: New test.
* gcc.target/riscv/rvv/base/binop_vv_constraint-4.c: Adapt testcase.
* gcc.target/riscv/rvv/base/binop_vv_constraint-6.c: Ditto.
* gcc.target/riscv/rvv/base/binop_vx_constraint-127.c: Ditto.
* gcc.target/riscv/rvv/base/spill-1.c: Ditto.
* gcc.target/riscv/rvv/base/spill-2.c: Ditto.
* gcc.target/riscv/rvv/base/spill-3.c: Ditto.
* gcc.target/riscv/rvv/base/spill-5.c: Ditto.
* gcc.target/riscv/rvv/base/spill-7.c: Ditto.
* g++.target/riscv/rvv/base/bug-18.C: New test.
* gcc.target/riscv/rvv/base/merge_constraint-3.c: New test.
* gcc.target/riscv/rvv/base/merge_constraint-4.c: New test.
15 files changed:
gcc/config/riscv/riscv-protos.h
gcc/config/riscv/riscv-v.cc
gcc/config/riscv/vector.md
gcc/testsuite/g++.target/riscv/rvv/base/bug-18.C [new file with mode: 0644]
gcc/testsuite/g++.target/riscv/rvv/base/pr109244.C [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/binop_vv_constraint-4.c
gcc/testsuite/gcc.target/riscv/rvv/base/binop_vv_constraint-6.c
gcc/testsuite/gcc.target/riscv/rvv/base/binop_vx_constraint-127.c
gcc/testsuite/gcc.target/riscv/rvv/base/merge_constraint-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/merge_constraint-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/base/spill-1.c
gcc/testsuite/gcc.target/riscv/rvv/base/spill-2.c
gcc/testsuite/gcc.target/riscv/rvv/base/spill-3.c
gcc/testsuite/gcc.target/riscv/rvv/base/spill-5.c
gcc/testsuite/gcc.target/riscv/rvv/base/spill-7.c