[aarch64/match.pd] Fix ICE observed in PR110280. gcc/ChangeLog: PR tree-optimization/110280 * match.pd (vec_perm_expr(v, v, mask) -> v): Explicitly build vector using build_vector_from_val with the element of input operand, and mask's type. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/pr110280.c: New test. diff --git a/gcc/match.pd b/gcc/match.pd index 2dd23826034..76a37297d3c 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -8672,7 +8672,12 @@ and, (simplify (vec_perm vec_same_elem_p@0 @0 @1) - @0) + (with + { + tree elem = uniform_vector_p (@0); + } + (if (elem) + { build_vector_from_val (type, elem); }))) /* Push VEC_PERM earlier if that may help FMA perception (PR101895). */ (simplify diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr110280.c b/gcc/testsuite/gcc.target/aarch64/sve/pr110280.c new file mode 100644 index 00000000000..d3279f38362 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/pr110280.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-tree-optimized" } */ + +#include "arm_sve.h" + +svuint32_t l() +{ + _Alignas(16) const unsigned int lanes[4] = {0, 0, 0, 0}; + return svld1rq_u32(svptrue_b8(), lanes); +} + +/* { dg-final { scan-tree-dump-not "VEC_PERM_EXPR" "optimized" } } */