diff options
author | Tamar Christina <tamar.christina@arm.com> | 2024-10-18 10:36:19 +0100 |
---|---|---|
committer | Tamar Christina <tamar.christina@arm.com> | 2024-10-18 10:36:19 +0100 |
commit | 55f898008ec8235897cf56c89f5599c3ec1bc963 (patch) | |
tree | fb66049a02ad3bfe3be5a9498fa633c3a11b4bc2 | |
parent | 453d3d90c374d3bb329f1431b7dfb8d0510a88b9 (diff) | |
download | gcc-55f898008ec8235897cf56c89f5599c3ec1bc963.zip gcc-55f898008ec8235897cf56c89f5599c3ec1bc963.tar.gz gcc-55f898008ec8235897cf56c89f5599c3ec1bc963.tar.bz2 |
middle-end: Fix VEC_PERM_EXPR lowering since relaxation of vector sizes
In GCC 14 VEC_PERM_EXPR was relaxed to be able to permute to a 2x larger vector
than the size of the input vectors. However various passes and transformations
were not updated to account for this.
I have patches in these area that I will be upstreaming with individual patches
that expose them.
This one is that vectlower tries to lower based on the size of the input vectors
rather than the size of the output. As a consequence it creates an invalid
vector of half the size.
Luckily we ICE because the resulting nunits doesn't match the vector size.
gcc/ChangeLog:
* tree-vect-generic.cc (lower_vec_perm): Use output vector size instead
of input vector when determining output nunits.
gcc/testsuite/ChangeLog:
* gcc.dg/vec-perm-lower.c: New test.
-rw-r--r-- | gcc/testsuite/gcc.dg/vec-perm-lower.c | 16 | ||||
-rw-r--r-- | gcc/tree-vect-generic.cc | 7 |
2 files changed, 20 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/vec-perm-lower.c b/gcc/testsuite/gcc.dg/vec-perm-lower.c new file mode 100644 index 0000000..da738fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vec-perm-lower.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple -O2" } */ + +typedef char v8qi __attribute__ ((vector_size (8))); +typedef char v16qi __attribute__ ((vector_size (16))); + +v16qi __GIMPLE (ssa) +foo (v8qi a, v8qi b) +{ + v16qi _5; + + __BB(2): + _5 = __VEC_PERM (a, b, _Literal (unsigned char [[gnu::vector_size(16)]]) { _Literal (unsigned char) 0, _Literal (unsigned char) 16, _Literal (unsigned char) 1, _Literal (unsigned char) 17, _Literal (unsigned char) 2, _Literal (unsigned char) 18, _Literal (unsigned char) 3, _Literal (unsigned char) 19, _Literal (unsigned char) 4, _Literal (unsigned char) 20, _Literal (unsigned char) 5, _Literal (unsigned char) 21, _Literal (unsigned char) 6, _Literal (unsigned char) 22, _Literal (unsigned char) 7, _Literal (unsigned char) 23 }); + return _5; + +} diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc index 3041fb8..f86f7ea 100644 --- a/gcc/tree-vect-generic.cc +++ b/gcc/tree-vect-generic.cc @@ -1500,6 +1500,7 @@ lower_vec_perm (gimple_stmt_iterator *gsi) tree mask = gimple_assign_rhs3 (stmt); tree vec0 = gimple_assign_rhs1 (stmt); tree vec1 = gimple_assign_rhs2 (stmt); + tree res_vect_type = TREE_TYPE (gimple_assign_lhs (stmt)); tree vect_type = TREE_TYPE (vec0); tree mask_type = TREE_TYPE (mask); tree vect_elt_type = TREE_TYPE (vect_type); @@ -1512,7 +1513,7 @@ lower_vec_perm (gimple_stmt_iterator *gsi) location_t loc = gimple_location (gsi_stmt (*gsi)); unsigned i; - if (!TYPE_VECTOR_SUBPARTS (vect_type).is_constant (&elements)) + if (!TYPE_VECTOR_SUBPARTS (res_vect_type).is_constant (&elements)) return; if (TREE_CODE (mask) == SSA_NAME) @@ -1672,9 +1673,9 @@ lower_vec_perm (gimple_stmt_iterator *gsi) } if (constant_p) - constr = build_vector_from_ctor (vect_type, v); + constr = build_vector_from_ctor (res_vect_type, v); else - constr = build_constructor (vect_type, v); + constr = build_constructor (res_vect_type, v); gimple_assign_set_rhs_from_tree (gsi, constr); update_stmt (gsi_stmt (*gsi)); } |