aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-11-30 14:08:19 +0100
committerRichard Biener <rguenther@suse.de>2021-11-30 15:01:25 +0100
commit0194d92c35ca8b3aa850b805d9becb4491cf6bec (patch)
treea4009cca2cc467eb5bbe664febb8e261b4d8c0d3 /gcc/tree-vect-loop.c
parent7e846b0f13b8a111484eb3a330044726b9d7ad79 (diff)
downloadgcc-0194d92c35ca8b3aa850b805d9becb4491cf6bec.zip
gcc-0194d92c35ca8b3aa850b805d9becb4491cf6bec.tar.gz
gcc-0194d92c35ca8b3aa850b805d9becb4491cf6bec.tar.bz2
tree-optimization/103489 - fix ICE when bool pattern recog fails
bool pattern recog currently does not handle cycles correctly and when it fails we can ICE later vectorizing PHIs with mismatched bool and non-bool vector types. The following avoids blindly trusting bool pattern recog here and verifies things more thoroughly in vectorizable_phi. A bool pattern recog fix is for GCC 13. 2021-11-30 Richard Biener <rguenther@suse.de> PR tree-optimization/103489 * tree-vect-loop.c (vectorizable_phi): Verify argument vector type compatibility to mitigate bool pattern recog bug. * gcc.dg/torture/pr103489.c: New testcase.
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 841da78..7f544ba 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -7846,6 +7846,24 @@ vectorizable_phi (vec_info *,
"incompatible vector types for invariants\n");
return false;
}
+ else if (SLP_TREE_DEF_TYPE (child) == vect_internal_def
+ && !useless_type_conversion_p (vectype,
+ SLP_TREE_VECTYPE (child)))
+ {
+ /* With bools we can have mask and non-mask precision vectors,
+ while pattern recog is supposed to guarantee consistency here
+ bugs in it can cause mismatches (PR103489 for example).
+ Deal with them here instead of ICEing later. */
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "incompatible vector type setup from "
+ "bool pattern detection\n");
+ gcc_checking_assert
+ (VECTOR_BOOLEAN_TYPE_P (SLP_TREE_VECTYPE (child))
+ != VECTOR_BOOLEAN_TYPE_P (vectype));
+ return false;
+ }
+
/* For single-argument PHIs assume coalescing which means zero cost
for the scalar and the vector PHIs. This avoids artificially
favoring the vector path (but may pessimize it in some cases). */