===================================================================
@@ -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);
===================================================================
@@ -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
+