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 part of PR30442


PR30442 shows that we do not vectorize basic-blocks if the to-be
vectorized data-references are followed by something that
find_data_references_in_stmt does not know how to analyze
(any call or asm for example).  The following re-organizes how
we create data-references in vect_analyze_data_refs for basic-blocks
employing the same trick as used later when analyzing them - stop
analysis at the stmt that we fail to analyze.

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

Richard.

2012-06-05  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/30442
	* tree-vect-data-refs.c (vect_analyze_data_refs): For basic-block
	vectorization stop analysis at the first stmt we cannot compute
	a data-reference for instead of giving up completely.

	* gcc.dg/vect/bb-slp-30.c: New testcase.

Index: gcc/tree-vect-data-refs.c
===================================================================
*** gcc/tree-vect-data-refs.c	(revision 188232)
--- gcc/tree-vect-data-refs.c	(working copy)
*************** vect_analyze_data_refs (loop_vec_info lo
*** 2844,2854 ****
      }
    else
      {
        bb = BB_VINFO_BB (bb_vinfo);
!       res = compute_data_dependences_for_bb (bb, true,
! 					     &BB_VINFO_DATAREFS (bb_vinfo),
! 					     &BB_VINFO_DDRS (bb_vinfo));
!       if (!res)
  	{
  	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
  	    fprintf (vect_dump, "not vectorized: basic block contains function"
--- 2844,2866 ----
      }
    else
      {
+       gimple_stmt_iterator gsi;
+ 
        bb = BB_VINFO_BB (bb_vinfo);
!       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
! 	{
! 	  gimple stmt = gsi_stmt (gsi);
! 	  if (!find_data_references_in_stmt (NULL, stmt,
! 					     &BB_VINFO_DATAREFS (bb_vinfo)))
! 	    {
! 	      /* Mark the rest of the basic-block as unvectorizable.  */
! 	      for (; !gsi_end_p (gsi); gsi_next (&gsi))
! 		STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (stmt)) = false;
! 	      break;
! 	    }
! 	}
!       if (!compute_all_dependences (BB_VINFO_DATAREFS (bb_vinfo),
! 				    &BB_VINFO_DDRS (bb_vinfo), NULL, true))
  	{
  	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
  	    fprintf (vect_dump, "not vectorized: basic block contains function"
Index: gcc/testsuite/gcc.dg/vect/bb-slp-30.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/bb-slp-30.c	(revision 0)
--- gcc/testsuite/gcc.dg/vect/bb-slp-30.c	(revision 0)
***************
*** 0 ****
--- 1,47 ----
+ /* { dg-require-effective-target vect_int } */
+ 
+ int a[32];
+ 
+ void __attribute__((noinline))
+ test1(void)
+ {
+   a[0] = 1;
+   a[1] = 1;
+   a[2] = 1;
+   a[3] = 1;
+   a[4] = 1;
+   a[5] = 1;
+   a[6] = 1;
+   a[7] = 1;
+   a[8] = 1;
+   a[9] = 1;
+   a[10] = 1;
+   a[11] = 1;
+   a[12] = 1;
+   a[13] = 1;
+   a[14] = 1;
+   a[15] = 1;
+   a[16] = 1;
+   a[17] = 1;
+   a[18] = 1;
+   a[19] = 1;
+   a[20] = 1;
+   a[21] = 1;
+   a[22] = 1;
+   a[23] = 1;
+   a[24] = 1;
+   a[25] = 1;
+   a[26] = 1;
+   a[27] = 1;
+   a[28] = 1;
+   a[29] = 1;
+   a[30] = 1;
+   a[31] = 1;
+   asm ("" : : : "memory");
+   a[21] = 0;
+ }
+ 
+ int main() { test1(); return a[21]; }
+ 
+ /* { dg-final { scan-tree-dump-times "basic block vectorized using SLP" 1 "slp" } } */
+ /* { dg-final { cleanup-tree-dump "slp" } } */


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