This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR58228


Invariant loads in the inner loop of a vectorized loop nest are not
supported, so make sure we don't run into the code that isn't prepared
to handle them.

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

Richard.

2013-08-30  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/58228
	* tree-vect-data-refs.c (vect_analyze_data_ref_access): Do not
	allow invariant loads in nested loop vectorization.

	* gcc.dg/torture/pr58228.c: New testcase.

Index: gcc/tree-vect-data-refs.c
===================================================================
*** gcc/tree-vect-data-refs.c	(revision 202068)
--- gcc/tree-vect-data-refs.c	(working copy)
*************** vect_analyze_data_ref_access (struct dat
*** 2272,2281 ****
        return false;
      }
  
!   /* Allow invariant loads in loops.  */
    if (loop_vinfo && integer_zerop (step))
      {
        GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = NULL;
        return DR_IS_READ (dr);
      }
  
--- 2272,2288 ----
        return false;
      }
  
!   /* Allow invariant loads in not nested loops.  */
    if (loop_vinfo && integer_zerop (step))
      {
        GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = NULL;
+       if (nested_in_vect_loop_p (loop, stmt))
+ 	{
+ 	  if (dump_enabled_p ())
+ 	    dump_printf_loc (MSG_NOTE, vect_location,
+ 			     "zero step in inner loop of nest");
+ 	  return false;
+ 	}
        return DR_IS_READ (dr);
      }
  
Index: gcc/testsuite/gcc.dg/torture/pr58228.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr58228.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr58228.c	(working copy)
***************
*** 0 ****
--- 1,15 ----
+ /* { dg-do run } */
+ 
+ extern void abort (void);
+ int a[8][8] = {{1}};
+ int b, c, d, e;
+ 
+ int main ()
+ {
+   for (c = 0; c < 8; c++)
+     for (b = 0; b < 2; b++)
+       a[b + 4][c] = a[c][0];
+   if (a[4][4] != 1)
+     abort ();
+   return 0;
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]