diff options
author | Richard Biener <rguenther@suse.de> | 2021-10-18 10:31:19 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-10-18 12:57:43 +0200 |
commit | eb032893675afea4b01cc6ad06a3e0dcfe9b51cd (patch) | |
tree | 1f0472932123b61a267eda11ecd9125fd0573497 /gcc/tree-vect-patterns.c | |
parent | 94dff03f67fad1f9c526bb915bb21a4deb19d638 (diff) | |
download | gcc-eb032893675afea4b01cc6ad06a3e0dcfe9b51cd.zip gcc-eb032893675afea4b01cc6ad06a3e0dcfe9b51cd.tar.gz gcc-eb032893675afea4b01cc6ad06a3e0dcfe9b51cd.tar.bz2 |
tree-optimization/102788 - avoid spurious bool pattern fails
Bool pattern recog is required for correctness since vectorized
compares otherwise produce -1 for true so any context where bool
is used as value and not as condition or mask needs to be replaced
with CMP ? 1 : 0. When we fail to find a vector type for the
result of such use we may not simply elide such transform since
a new bool result can emerge when for example the cast_forwprop
pattern is applied. So the following avoids failing of the
bool pattern recog process and instead not assign a vector type
for the stmt.
2021-10-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/102788
* tree-vect-patterns.c (vect_init_pattern_stmt): Allow
a NULL vectype.
(vect_pattern_recog_1): Likewise.
(vect_recog_bool_pattern): Continue matching the pattern
even if we do not have a vector type for a conversion
result.
* g++.dg/vect/pr102788.cc: New testcase.
Diffstat (limited to 'gcc/tree-vect-patterns.c')
-rw-r--r-- | gcc/tree-vect-patterns.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index e6c5bcd..854cbcf 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -119,8 +119,9 @@ vect_init_pattern_stmt (vec_info *vinfo, gimple *pattern_stmt, = STMT_VINFO_DEF_TYPE (orig_stmt_info); if (!STMT_VINFO_VECTYPE (pattern_stmt_info)) { - gcc_assert (VECTOR_BOOLEAN_TYPE_P (vectype) - == vect_use_mask_type_p (orig_stmt_info)); + gcc_assert (!vectype + || (VECTOR_BOOLEAN_TYPE_P (vectype) + == vect_use_mask_type_p (orig_stmt_info))); STMT_VINFO_VECTYPE (pattern_stmt_info) = vectype; pattern_stmt_info->mask_precision = orig_stmt_info->mask_precision; } @@ -4283,8 +4284,6 @@ vect_recog_bool_pattern (vec_info *vinfo, || VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (lhs))) return NULL; vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs)); - if (vectype == NULL_TREE) - return NULL; if (check_bool_pattern (var, vinfo, bool_stmts)) { @@ -5696,7 +5695,6 @@ vect_pattern_recog_1 (vec_info *vinfo, } loop_vinfo = dyn_cast <loop_vec_info> (vinfo); - gcc_assert (pattern_vectype); /* Found a vectorizable pattern. */ if (dump_enabled_p ()) |