diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2016-01-27 05:43:00 -0200 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2016-01-27 05:43:00 -0200 |
commit | 4ccc88e6b3810600b82d519967be74495b6431e1 (patch) | |
tree | 0198ad98cec05f97e07e9cab2b63800d3e171bd2 | |
parent | 8d96cf4098e10fc2911d2bd1a0c885861ecf146c (diff) | |
download | gcc-aoliva/pr69466.tar.gz |
[PR69466] fix loop vectorizer set_current_defaoliva/pr69466
slpeel_duplicate_current_defs_from_edges is often called with edges to
blocks that were copied from one another, but it isn't always so.
Check that their phi nodes match before calling set_current_def for
any of them.
for gcc/ChangeLog
PR target/69466
* tree-vect-loop-manip.c
(slpeel_duplicate_current_defs_from_edges): Skip if dest blocks
don't have phi nodes for names for the same base variables.
for gcc/testsuite/ChangeLog
PR target/69466
* gfortran.dg/vect/pr69466.f90: New.
-rw-r--r-- | gcc/testsuite/gfortran.dg/vect/pr69466.f90 | 42 | ||||
-rw-r--r-- | gcc/tree-vect-loop-manip.c | 16 |
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); |