summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/testsuite/gfortran.dg/vect/pr69466.f9042
-rw-r--r--gcc/tree-vect-loop-manip.c16
2 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/vect/pr69466.f90 b/gcc/testsuite/gfortran.dg/vect/pr69466.f90
new file mode 100644
index 00000000000..a01950f1ac8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/vect/pr69466.f90
@@ -0,0 +1,42 @@
+! { dg-do compile }
+! { dg-additional-options "-march=core-avx2" { target x86_64-*-* i?86-*-* } }
+
+ subroutine foo
+
+ integer :: a, b, c, d, e
+
+ integer, dimension(:), allocatable :: f, g, h
+
+ call zoo (a)
+ call zoo (b)
+ call zoo (c)
+
+ if(a == b) then
+ allocate(g(0:d-1), h(0:d-1))
+ else
+ allocate(g(1), h(1))
+ if (b /= 0) then
+ call zoo(b)
+ endif
+ endif
+
+ if(a == b) then
+ do d=0,c-1
+ e = e + g(d)
+ if(d == 0) then
+ h(d) = 0
+ else
+ h(d) = h(d-1) + g(d-1)
+ endif
+ end do
+ endif
+
+ if(a == b) then
+ allocate(f(e), g(e))
+ endif
+
+ if(a == 0) then
+ call boo(e)
+ endif
+
+ end subroutine foo
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index f9fdf013e10..35c5435b76e 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -725,6 +725,22 @@ slpeel_duplicate_current_defs_from_edges (edge from, edge to)
{
gimple_stmt_iterator gsi_from, gsi_to;
+ /* Check that we're looking at two blocks with analogous PHI
+ nodes before changing anything. */
+ for (gsi_from = gsi_start_phis (from->dest),
+ gsi_to = gsi_start_phis (to->dest);
+ !gsi_end_p (gsi_from) && !gsi_end_p (gsi_to);
+ gsi_next (&gsi_from), gsi_next (&gsi_to))
+ {
+ gimple *from_phi = gsi_stmt (gsi_from);
+ gimple *to_phi = gsi_stmt (gsi_to);
+ if (SSA_NAME_VAR (PHI_RESULT (from_phi))
+ != SSA_NAME_VAR (PHI_RESULT (to_phi)))
+ return;
+ }
+ if (gsi_end_p (gsi_from) != gsi_end_p (gsi_to))
+ return;
+
for (gsi_from = gsi_start_phis (from->dest),
gsi_to = gsi_start_phis (to->dest);
!gsi_end_p (gsi_from) && !gsi_end_p (gsi_to);