]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Allow RVV VMS{Compare}(V1, V1) simplify to VMCLR
authorPan Li <pan2.li@intel.com>
Fri, 28 Apr 2023 02:46:41 +0000 (10:46 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Fri, 28 Apr 2023 12:37:14 +0000 (20:37 +0800)
commit8b84d87969ef2443516a79a80c22d2b6dba04630
treef303c9e2eeab5d0ff4ee0d8ed4b59d8fc8498730
parentd711f8f81fc5f3a5a0420337f414bce93e1cad1e
RISC-V: Allow RVV VMS{Compare}(V1, V1) simplify to VMCLR

When some RVV integer compare operators act on the same vector
registers without mask. They can be simplified to VMCLR.

This PATCH allow the ne, lt, ltu, gt, gtu to perform such kind
of the simplification by adding one new define_split.

Given we have:
vbool1_t test_shortcut_for_riscv_vmslt_case_0(vint8m8_t v1, size_t vl) {
  return __riscv_vmslt_vv_i8m8_b1(v1, v1, vl);
}

Before this patch:
vsetvli  zero,a2,e8,m8,ta,ma
vl8re8.v v24,0(a1)
vmslt.vv v8,v24,v24
vsetvli  a5,zero,e8,m8,ta,ma
vsm.v    v8,0(a0)
ret

After this patch:
vsetvli zero,a2,e8,mf8,ta,ma
vmclr.m v24                    <- optimized to vmclr.m
vsetvli zero,a5,e8,mf8,ta,ma
vsm.v   v24,0(a0)
ret

As above, we may have one instruction eliminated and require less
vector registers.

gcc/ChangeLog:

* config/riscv/vector.md: Add new define split to perform
the simplification.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
Co-authored-by: kito-cheng <kito.cheng@sifive.com>
gcc/config/riscv/vector.md
gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c [new file with mode: 0644]