]> gcc.gnu.org Git - gcc.git/commit
tree-optimization/110897 - Fix missed vectorization of shift on both RISC-V and aarch64
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Mon, 7 Aug 2023 01:54:31 +0000 (09:54 +0800)
committerLehua Ding <lehua.ding@rivai.ai>
Mon, 7 Aug 2023 10:03:16 +0000 (18:03 +0800)
commitc5f673dbc252e35e6b66e9b8abd30a4027193e0b
treede9032abc1ccc9489b0528ee0f85478bdfb0481e
parenta016c8cb03e2b3175e48b2f81d81ad39abef5b54
tree-optimization/110897 - Fix missed vectorization of shift on both RISC-V and aarch64

Consider this following case:

#include <stdint.h>

#define TEST2_TYPE(TYPE) \
  __attribute__((noipa)) \
  void vshiftr_##TYPE (TYPE *__restrict dst, TYPE *__restrict a, TYPE *__restrict b, int n) \
  { \
    for (int i = 0; i < n; i++) \
      dst[i] = (a[i]) >> b[i]; \
  }

#define TEST_ALL() \
 TEST2_TYPE(uint8_t) \
 TEST2_TYPE(uint16_t) \
 TEST2_TYPE(uint32_t) \
 TEST2_TYPE(uint64_t) \

TEST_ALL()

Both RISC-V and aarch64 of trunk GCC failed vectorize uint8_t/uint16_t with following missed report:

<source>:17:1: missed: couldn't vectorize loop
<source>:17:1: missed: not vectorized: relevant stmt not supported: patt_46 = MIN_EXPR <_6, 7>;
<source>:17:1: missed: couldn't vectorize loop
<source>:17:1: missed: not vectorized: relevant stmt not supported: patt_47 = MIN_EXPR <_7, 15>;
Compiler returned: 0

Both GCC 13.1 can vectorize, see:

https://godbolt.org/z/6vaMK5M1o

Bootstrap and regression on X86 passed.

Ok for trunk ?

gcc/ChangeLog:

* tree-vect-patterns.cc (vect_recog_over_widening_pattern): Add op vectype.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/narrow-1.c: Adapt testcase.
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/narrow-1.c
gcc/tree-vect-patterns.cc
This page took 0.069408 seconds and 6 git commands to generate.