aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-11-14 14:58:21 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-11-14 14:58:21 +0000
commit0203c4f3bfb3e3242635b0cee0b9deedb4070a62 (patch)
tree63619b1cbf82629c2813b07094e310e23df0e5cc
parent95da266b86fcdeff84fcadc5e3cde3d0027e571d (diff)
downloadgcc-0203c4f3bfb3e3242635b0cee0b9deedb4070a62.zip
gcc-0203c4f3bfb3e3242635b0cee0b9deedb4070a62.tar.gz
gcc-0203c4f3bfb3e3242635b0cee0b9deedb4070a62.tar.bz2
Use consistent compatibility checks in vectorizable_shift
The validation phase of vectorizable_shift used TYPE_MODE to check whether the shift amount vector was compatible with the shifted vector: if ((op1_vectype == NULL_TREE || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype)) && (!slp_node || SLP_TREE_DEF_TYPE (SLP_TREE_CHILDREN (slp_node)[1]) != vect_constant_def)) But the generation phase was stricter and required the element types to be equivalent: && !useless_type_conversion_p (TREE_TYPE (vectype), TREE_TYPE (op1))) This difference led to an ICE with a later patch. The first condition seems a bit too lax given that the function supports vect_worthwhile_without_simd_p, where two different vector types could have the same integer mode. But it seems too strict to reject signed shifts by unsigned amounts or unsigned shifts by signed amounts; verify_gimple_assign_binary is happy with those. This patch therefore goes for a middle ground of checking both TYPE_MODE and TYPE_VECTOR_SUBPARTS, using the same condition in both places. 2019-11-14 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-stmts.c (vectorizable_shift): Check the number of vector elements as well as the type mode when deciding whether an op1_vectype is compatible. Reuse the result of this check when generating vector statements. From-SVN: r278235
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-vect-stmts.c13
2 files changed, 15 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 210a9c4..70e50ae 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
+ * tree-vect-stmts.c (vectorizable_shift): Check the number
+ of vector elements as well as the type mode when deciding
+ whether an op1_vectype is compatible. Reuse the result of
+ this check when generating vector statements.
+
+2019-11-14 Richard Sandiford <richard.sandiford@arm.com>
+
* tree-vect-stmts.c (get_vectype_for_scalar_type_and_size): If
targetm.vectorize.preferred_simd_mode returns an integer mode,
use mode_for_vector to decide what the vector type's mode
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 9361a23..15c798d 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -5544,6 +5544,7 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
bool scalar_shift_arg = true;
bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
vec_info *vinfo = stmt_info->vinfo;
+ bool incompatible_op1_vectype_p = false;
if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo)
return false;
@@ -5688,8 +5689,12 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
if (!op1_vectype)
op1_vectype = get_same_sized_vectype (TREE_TYPE (op1), vectype_out);
- if ((op1_vectype == NULL_TREE
- || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype))
+ incompatible_op1_vectype_p
+ = (op1_vectype == NULL_TREE
+ || maybe_ne (TYPE_VECTOR_SUBPARTS (op1_vectype),
+ TYPE_VECTOR_SUBPARTS (vectype))
+ || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype));
+ if (incompatible_op1_vectype_p
&& (!slp_node
|| SLP_TREE_DEF_TYPE
(SLP_TREE_CHILDREN (slp_node)[1]) != vect_constant_def))
@@ -5835,9 +5840,7 @@ vectorizable_shift (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
}
}
}
- else if (slp_node
- && !useless_type_conversion_p (TREE_TYPE (vectype),
- TREE_TYPE (op1)))
+ else if (slp_node && incompatible_op1_vectype_p)
{
if (was_scalar_shift_arg)
{