Skip to content
Snippets Groups Projects
Commit 63dc25ed authored by Pan Li's avatar Pan Li
Browse files

RISC-V: Support FP floor 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     |
+----------+-----------+----------+
| ifloor   | DF => SI  | DF => SI |
| ifloorf  | -         | -        |
| lfloor   | -         | DF => SI |
| lfloorf  | SF => DI  | -        |
| llfloor  | -         | -        |
| llfloorf | SF => DI  | SF => DI |
+----------+-----------+----------+

Given below code:
void
test_lfloorf (long *out, float *in, unsigned count)
{
  for (unsigned i = 0; i < count; i++)
    out[i] = __builtin_lceilf (in[i]);
}

Before this patch:
.L3:
  flw      fa0,0(s0)
  addi     s0,s0,4
  addi     s1,s1,8
  call     floorf
  fcvt.l.s a5,fa0,rtz
  sd       a5,-8(s1)
  bne      s2,s0,.L3

After this patch:
  fsrmi        2  // RDN mode
.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 lfloor.
	* config/riscv/riscv-v.cc (expand_vec_lfloor): Leverage
	emit_vec_rounding_to_integer for floor.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/unop/math-ifloor-1.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-ifloor-run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lfloor-rv32-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lfloor-rv32-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lfloorf-rv64-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lfloorf-rv64-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-llfloorf-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-llfloorf-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-ifloor-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-lfloor-rv32-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-lfloorf-rv64-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-llfloorf-0.c: New test.

Signed-off-by: default avatarPan Li <pan2.li@intel.com>
parent f5ddc367
No related branches found
No related tags found
No related merge requests found
Showing
with 520 additions and 9 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment