]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Support FP irintf auto vectorization
authorPan Li <pan2.li@intel.com>
Thu, 12 Oct 2023 01:43:02 +0000 (09:43 +0800)
committerPan Li <pan2.li@intel.com>
Thu, 12 Oct 2023 02:06:06 +0000 (10:06 +0800)
commitd6b7fe11efe9c7bf44dfe57ded6c86df5ec7e2c7
tree1f174701c97d88e04fd1b70fab4d9fa426bab44e
parent6febf76c4e19cc86a4d8020f9f0349ba05aba223
RISC-V: Support FP irintf auto vectorization

This patch would like to support the FP irintf auto vectorization.

* int irintf (float)

Due to the limitation that only the same size of data type are allowed
in the vectorier, the standard name lrintmn2 only act on SF => SI.

Given we have code like:

void
test_irintf (int *out, float *in, unsigned count)
{
  for (unsigned i = 0; i < count; i++)
    out[i] = __builtin_irintf (in[i]);
}

Before this patch:
.L3:
  ...
  flw      fa5,0(a1)
  fcvt.w.s a5,fa5,dyn
  sw       a5,-4(a0)
  ...
  bne      a1,a4,.L3

After this patch:
.L3:
  ...
  vle32.v     v1,0(a1)
  vfcvt.x.f.v v1,v1
  vse32.v     v1,0(a0)
  ...
  bne         a2,zero,.L3

The rest part like DF => SI/HF => SI will be covered by the hook
TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION.

gcc/ChangeLog:

* config/riscv/autovec.md (lrint<mode><vlconvert>2): Rename from.
(lrint<mode><v_i_l_ll_convert>2): Rename to.
* config/riscv/vector-iterators.md: Rename and remove TARGET_64BIT.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/unop/math-irint-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-irint-0.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/config/riscv/autovec.md
gcc/config/riscv/vector-iterators.md
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-0.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-0.c [new file with mode: 0644]