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

RISC-V: Support FP ceil 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     |
+---------+-----------+----------+
| iceil   | DF => SI  | DF => SI |
| iceilf  | -         | -        |
| lceil   | -         | DF => SI |
| lceilf  | SF => DI  | -        |
| llceil  | -         | -        |
| llceilf | SF => DI  | SF => DI |
+---------+-----------+----------+

Given below code:
void
test_lceilf (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     ceilf
  fcvt.l.s a5,fa0,rtz
  sd       a5,-8(s1)
  bne      s2,s0,.L3
  ld       ra,24(sp)
  ld       s0,16(sp)
  ld       s1,8(sp)
  ld       s2,0(sp)
  addi     sp,sp,32
  jr       ra

After this patch:
  fsrmi        3  // RUP 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 lceil.l
	* config/riscv/riscv-v.cc (expand_vec_lceil):  Leverage
	emit_vec_rounding_to_integer for ceil.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c: New test.

Signed-off-by: default avatarPan Li <pan2.li@intel.com>
parent b7d05f13
No related branches found
No related tags found
Loading
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