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 PR70726


I am testing the following to fix PR70726.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2016-04-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/70726
	* tree-vect-stmts.c (vectorizable_shift): Do not use scalar
	shift amounts from a pattern stmt operand.

	* g++.dg/vect/pr70726.cc: New testcase.

Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c	(revision 235188)
--- gcc/tree-vect-stmts.c	(working copy)
*************** vectorizable_shift (gimple *stmt, gimple
*** 4532,4537 ****
--- 4532,4547 ----
  	    if (!operand_equal_p (gimple_assign_rhs2 (slpstmt), op1, 0))
  	      scalar_shift_arg = false;
  	}
+ 
+       /* If the shift amount is computed by a pattern stmt we cannot
+          use the scalar amount directly thus give up and use a vector
+ 	 shift.  */
+       if (dt[1] == vect_internal_def)
+ 	{
+ 	  gimple *def = SSA_NAME_DEF_STMT (op1);
+ 	  if (is_pattern_stmt_p (vinfo_for_stmt (def)))
+ 	    scalar_shift_arg = false;
+ 	}
      }
    else
      {
Index: gcc/testsuite/g++.dg/vect/pr70726.cc
===================================================================
*** gcc/testsuite/g++.dg/vect/pr70726.cc	(revision 0)
--- gcc/testsuite/g++.dg/vect/pr70726.cc	(working copy)
***************
*** 0 ****
--- 1,19 ----
+ // { dg-do compile }
+ // { dg-additional-options "-Ofast" }
+ // { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } }
+ 
+ extern long a;
+ extern int b[100];
+ extern unsigned c[5][5][2][4][2][2][3];
+ void fn1() {
+   for (int d = 0; d < 2; d = d + 1)
+     for (int e = 0; e < 5; e = e + 1)
+       for (int f = 0; f < 3; f = f + 1)
+         for (int g = 0; g < 3; g = g + 1)
+           for (int h = 0; h < 2; h = h + 1)
+             for (int i = 0; i < 4; i = i + 1)
+               for (int j = 0; j < 2; j = j + 1)
+                 for (int k = 0; k < 2; k = k + 1)
+                   for (int l = 0; l < 3; l = l + 1)
+                     c[d][e][h][i][j][k][l] = a << b[f * 5 + g] + 4;
+ }


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