diff options
author | Pan Li <pan2.li@intel.com> | 2023-11-05 10:37:27 +0800 |
---|---|---|
committer | Pan Li <pan2.li@intel.com> | 2023-11-05 17:41:25 +0800 |
commit | 9acea4376fd98696ba51e59f417c94911a4d8248 (patch) | |
tree | 750e7f1a2b49b1e245589a216053a105d80feb4e /gcc/tree-vect-loop-manip.cc | |
parent | 53010f6ff6dfbf7bcd40055cf00d9f8e653cc641 (diff) | |
download | gcc-9acea4376fd98696ba51e59f417c94911a4d8248.zip gcc-9acea4376fd98696ba51e59f417c94911a4d8248.tar.gz gcc-9acea4376fd98696ba51e59f417c94911a4d8248.tar.bz2 |
RISC-V: Support FP rint to i/l/ll diff size autovec
This patch would like to support the FP below API auto vectorization
with different type size
+---------+-----------+----------+
| API | RV64 | RV32 |
+---------+-----------+----------+
| irint | DF => SI | DF => SI |
| irintf | - | - |
| lrint | - | DF => SI |
| lrintf | SF => DI | - |
| llrint | - | - |
| llrintf | SF => DI | SF => DI |
+---------+-----------+----------+
Given below code:
void
test_lrintf (long *out, float *in, unsigned count)
{
for (unsigned i = 0; i < count; i++)
out[i] = __builtin_lrintf (in[i]);
}
Before this patch:
test_lrintf:
beq a2,zero,.L8
slli a5,a2,32
srli a2,a5,30
add a4,a1,a2
.L3:
flw fa5,0(a1)
addi a1,a1,4
addi a0,a0,8
fcvt.l.s a5,fa5,dyn
sd a5,-8(a0)
bne a1,a4,.L3
After this patch:
test_lrintf:
beq a2,zero,.L8
slli a2,a2,32
srli a2,a2,32
.L3:
vsetvli a5,a2,e32,mf2,ta,ma
vle32.v v2,0(a1)
slli a3,a5,2
slli a4,a5,3
vfwcvt.x.f.v v1,v2
sub a2,a2,a5
vse64.v v1,0(a0)
add a1,a1,a3
add a0,a0,a4
bne a2,zero,.L3
Unfortunately, the HF mode is not include due to it requires
additional middle-end support from internal-fun.def.
gcc/ChangeLog:
* config/riscv/autovec.md: Remove the size check of lrint.
* config/riscv/riscv-v.cc (emit_vec_narrow_cvt_x_f): New help
emit func impl.
(emit_vec_widden_cvt_x_f): New help emit func impl.
(emit_vec_rounding_to_integer): New func impl to emit the
rounding from FP to integer.
(expand_vec_lrint): Leverage emit_vec_rounding_to_integer.
* config/riscv/vector.md: Take V_VLSF for vfncvt.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c:
* gcc.target/riscv/rvv/autovec/unop/math-irint-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-irint-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c: New test.
Signed-off-by: Pan Li <pan2.li@intel.com>
Diffstat (limited to 'gcc/tree-vect-loop-manip.cc')
0 files changed, 0 insertions, 0 deletions