We have to verify the PHI argument nodes insertion place dominates
the PHI argument edge sources.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/126852
* tree-vect-slp.cc (vect_schedule_slp_node): Verify schedule
for PHIs.
* gcc.dg/vect/bb-slp-pr126852.c: New testcase.
---
gcc/testsuite/gcc.dg/vect/bb-slp-pr126852.c | 25 +++++++++++++++++++++
gcc/tree-vect-slp.cc | 10 +++++++++
2 files changed, 35 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/vect/bb-slp-pr126852.c
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr126852.c
b/gcc/testsuite/gcc.dg/vect/bb-slp-pr126852.c
new file mode 100644
index 00000000000..5391a08d314
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr126852.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3 -fno-tree-pre" } */
+/* { dg-additional-options "-mavx2" { target avx2 } } */
+
+int a;
+long b, c;
+__attribute__((noinline)) int d() {
+ a = 0;
+ return 0;
+}
+void e(char f, char g, long h, long i) {
+ char j;
+k:
+ do {
+ j = 2 * f;
+ if (!g)
+ return;
+ d();
+ if (g << g)
+ goto k;
+ unsigned long m = b;
+ long n = m >> 8;
+ c = n + 2088470516281635866 * i + h * h + 7017580219 * i;
+ } while (j < f + 2);
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index e60232c20c3..89a67e4eb38 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -12115,6 +12115,16 @@ vect_schedule_slp_node (vec_info *vinfo,
{
/* For PHI node vectorization we do not use the insertion iterator. */
last_stmt = SLP_TREE_SCALAR_STMTS (node)[0]->stmt;
+ if (place_only)
+ FOR_EACH_VEC_ELT (SLP_TREE_CHILDREN (node), i, child)
+ {
+ if (child->si
+ && !dominated_by_p (CDI_DOMINATORS,
+ gimple_phi_arg_edge
+ (as_a <gphi *> (last_stmt), i)->src,
+ gimple_bb (child->si)))
+ return false;
+ }
si = gsi_none ();
}
else
--
2.51.0