diff mbox

Fix PR68817

Message ID alpine.LSU.2.11.1512101422090.4884@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Dec. 10, 2015, 1:22 p.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

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

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

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

Patch

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
+