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

Richard.

2015-12-10  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/68817
        * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Detect
        gaps early.

        * gfortran.dg/pr68817.f90: New testcase.

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c (revision 231499)
+++ gcc/tree-vect-slp.c (working copy)
@@ -1237,6 +1237,8 @@ vect_attempt_slp_rearrange_stmts (slp_in
   bitmap_clear (load_index);
   FOR_EACH_VEC_ELT (node->load_permutation, i, lidx)
     {
+      if (lidx >= group_size)
+       return false;
       if (bitmap_bit_p (load_index, lidx))
        {
          sbitmap_free (load_index);
Index: gcc/testsuite/gfortran.dg/pr68817.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr68817.f90       (revision 0)
+++ gcc/testsuite/gfortran.dg/pr68817.f90       (working copy)
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-O3 -ffast-math" }
+      SUBROUTINE TEST(A,B,C)
+      DIMENSION B(3),C(1000,10)
+      DO I = 1,3
+         I3=I*3
+         B(1) = B(1) + (C(K,I3+1)-A)
+         B(3) = B(3) + (C(K,I3+3)-A)
+      ENDDO
+      END
+

Reply via email to