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.
This commit is contained in:
parent
453d3d90c3
commit
55f898008e
2 changed files with 20 additions and 3 deletions
16
gcc/testsuite/gcc.dg/vec-perm-lower.c
Normal file
16
gcc/testsuite/gcc.dg/vec-perm-lower.c
Normal file
|
@ -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;
|
||||
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue