]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Legitimise the const0_rtx for RVV indexed load/store
authorPan Li <pan2.li@intel.com>
Thu, 4 May 2023 09:11:18 +0000 (17:11 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Fri, 5 May 2023 14:51:19 +0000 (22:51 +0800)
commit0c1eaac3fd35eafedc8fb5638af30af0aea199d3
tree358e8b4749f89726238cb0ceef09b9fdf808e6d1
parent3365956d55a6484097ff40fb81acb2345322044c
RISC-V: Legitimise the const0_rtx for RVV indexed load/store

This patch try to legitimise the const0_rtx (aka zero register)
as the base register for the RVV indexed load/store instructions
by allowing the const as the operand of the indexed RTL pattern.
Then the underlying combine pass will try to perform the const
propagation.

For example:
vint32m1_t
test_vluxei32_v_i32m1_shortcut (vuint32m1_t bindex, size_t vl)
{
  return __riscv_vluxei32_v_i32m1 ((int32_t *)0, bindex, vl);
}

Before this patch:
li         a5,0                 <- can be eliminated.
vl1re32.v  v1,0(a1)
vsetvli    zero,a2,e32,m1,ta,ma
vluxei32.v v1,(a5),v1           <- can propagate the const 0 to a5 here.
vs1r.v     v1,0(a0)
ret

After this patch:
test_vluxei32_v_i32m1_shortcut:
vl1re32.v       v1,0(a1)
vsetvli zero,a2,e32,m1,ta,ma
vluxei32.v      v1,(0),v1
vs1r.v  v1,0(a0)
ret

As above, this patch allow you to propagaate the const 0 (aka zero
register) to the base register of the RVV indexed load in the combine
pass. This may benefit the underlying RVV auto-vectorization.

gcc/ChangeLog:

* config/riscv/vector.md: Allow const as the operand of RVV
indexed load/store.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/zero_base_load_store_optimization.c:
Adjust indexed load/store check condition.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-authored-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
gcc/config/riscv/vector.md
gcc/testsuite/gcc.target/riscv/rvv/base/zero_base_load_store_optimization.c