RISC-V: Support FP round 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 |
+----------+-----------+----------+
| iround | DF => SI | DF => SI |
| iroundf | - | - |
| lround | - | DF => SI |
| lroundf | SF => DI | - |
| llround | - | - |
| llroundf | SF => DI | SF => DI |
+----------+-----------+----------+
Given below code:
void
test_lroundf (long *out, float *in, unsigned count)
{
for (unsigned i = 0; i < count; i++)
out[i] = __builtin_lroundf (in[i]);
}
Before this patch:
.L3:
flw fa5,0(a1)
addi a1,a1,4
addi a0,a0,8
fcvt.l.s a5,fa5,rmm
sd a5,-8(a0)
bne a4,a1,.L3
After this patch:
fsrmi 4 // RMM rounding mode
vsetivli zero,16,e32,m4,ta,ma
.L4:
vle32.v v4,0(a5)
addi a5,a5,64
vfwcvt.x.f.v v8,v4
vse64.v v8,0(a4)
addi a4,a4,128
bne a3,a5,.L4
andi a5,a2,15
andi a4,a2,-16
beq a5,zero,.L16
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 lround.
* config/riscv/riscv-v.cc (expand_vec_lround): Leverage
emit_vec_rounding_to_integer for round.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/unop/math-iround-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-iround-run-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llroundf-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llroundf-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lround-rv32-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lroundf-rv64-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-iround-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-llroundf-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lround-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lroundf-rv64-0.c: New test.
Signed-off-by: Pan Li <pan2.li@intel.com>
14 files changed: