diff mbox series

tree-optimization/103800 - sanity check more PHI vectorization

Message ID rp17379n-n91r-273n-qnr-5848986011n2@fhfr.qr
State New
Headers show
Series tree-optimization/103800 - sanity check more PHI vectorization | expand

Commit Message

Richard Biener Jan. 4, 2022, 3:51 p.m. UTC
Bool pattern detection doesn't really handle PHIs well so we have
to be prepared for mismatched vector types in more cases than
originally thought.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2022-01-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/103800
	* tree-vect-loop.c (vectorizable_phi): Remove assert and
	expand comment.

	* gcc.dg/vect/bb-slp-pr103800.c: New testcase.
---
 gcc/testsuite/gcc.dg/vect/bb-slp-pr103800.c | 17 +++++++++++++++++
 gcc/tree-vect-loop.c                        | 10 ++++------
 2 files changed, 21 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr103800.c
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr103800.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr103800.c
new file mode 100644
index 00000000000..33c2d2081cf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr103800.c
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+int a;
+long b;
+extern int c[], d[];
+extern _Bool e[];
+void f() {
+  if (a)
+    ;
+  for (;;) {
+    for (int g = 2; g; g = a)
+      d[g] = 0;
+    for (int h = 1; h < 13; h++)
+      e[h] = b ? (short)c[4 + h - 1] : c[4 + h - 1];
+  }
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index ebd7d9c2218..77f1cc0f788 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -7850,17 +7850,15 @@  vectorizable_phi (vec_info *,
 		 && !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).
+	    /* With bools we can have mask and non-mask precision vectors
+	       or different non-mask precisions.  while pattern recog is
+	       supposed to guarantee consistency here bugs in it can cause
+	       mismatches (PR103489 and PR103800 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;
 	  }