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 PR69907


The following fixes PR69907, BB vectorization not properly avoiding
loading excess elements beyond the last scalar access.  As seen by
the testsuite adjustments this pessimizes the cases where we'd know
the underlying object is larger, but that's a general issue also
for loop vectorization with gaps.

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

Richard.

2016-02-24  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/69907
	* tree-vect-stmts.c (vectorizable_load): Check for gaps at the
	end of permutations for BB vectorization.

	* gcc.dg/vect/bb-slp-pr69907.c: New testcase.
	* gcc.dg/vect/bb-slp-34.c: XFAIL.
	* gcc.dg/vect/bb-slp-pr68892.c: Likewise.

Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c	(revision 233620)
--- gcc/tree-vect-stmts.c	(working copy)
*************** vectorizable_load (gimple *stmt, gimple_
*** 6395,6400 ****
--- 6394,6412 ----
  	slp_perm = true;
  
        group_size = GROUP_SIZE (vinfo_for_stmt (first_stmt));
+ 
+       /* ???  The following is overly pessimistic (as well as the loop
+          case above) in the case we can statically determine the excess
+ 	 elements loaded are within the bounds of a decl that is accessed.
+ 	 Likewise for BB vectorizations using masked loads is a possibility.  */
+       if (bb_vinfo && slp_perm && group_size % nunits != 0)
+ 	{
+ 	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ 			   "BB vectorization with gaps at the end of a load "
+ 			   "is not supported\n");
+ 	  return false;
+ 	}
+ 
        if (!slp
  	  && !PURE_SLP_STMT (stmt_info)
  	  && !STMT_VINFO_STRIDED_P (stmt_info))
Index: gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c	(revision 0)
--- gcc/testsuite/gcc.dg/vect/bb-slp-pr69907.c	(working copy)
***************
*** 0 ****
--- 1,12 ----
+ /* { dg-do compile } */
+ /* { dg-additional-options "-O3" } */
+ /* { dg-require-effective-target vect_unpack } */
+ 
+ void foo(unsigned *p1, unsigned short *p2)
+ {
+   int n;
+   for (n = 0; n < 320; n++)
+     p1[n] = p2[n * 2];
+ }
+ 
+ /* { dg-final { scan-tree-dump "BB vectorization with gaps at the end of a load is not supported" "slp1" } } */
Index: gcc/testsuite/gcc.dg/vect/bb-slp-34.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/bb-slp-34.c	(revision 233620)
--- gcc/testsuite/gcc.dg/vect/bb-slp-34.c	(working copy)
*************** int main()
*** 32,35 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump "basic block vectorized" "slp2" { target vect_perm } } } */
--- 32,36 ----
    return 0;
  }
  
! /* ??? XFAILed because we access "excess" elements with the permutation.  */
! /* { dg-final { scan-tree-dump "basic block vectorized" "slp2" { target vect_perm xfail *-*-* } } } */
Index: gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c	(revision 233620)
--- gcc/testsuite/gcc.dg/vect/bb-slp-pr68892.c	(working copy)
*************** void foo(void)
*** 13,17 ****
    b[3] = a[3][0];
  }
  
! /* { dg-final { scan-tree-dump "not profitable" "slp2" } } */
  /* { dg-final { scan-tree-dump-times "Basic block will be vectorized" 0 "slp2" } } */
--- 13,19 ----
    b[3] = a[3][0];
  }
  
! /* ???  The profitability check is not reached because we give up on the
!    gaps we access earlier.  */
! /* { dg-final { scan-tree-dump "not profitable" "slp2" { xfail *-*-* } } } */
  /* { dg-final { scan-tree-dump-times "Basic block will be vectorized" 0 "slp2" } } */


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