public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR tree-optimization/68413 : Only check for integer cond reduction on analysis stage
@ 2015-11-20  9:24 Alan Hayward
  2015-11-20 11:00 ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Hayward @ 2015-11-20  9:24 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 676 bytes --]

When vectorising a integer induction condition reduction,
is_nonwrapping_integer_induction ends up with different values for base
during the analysis and build phases. In the first it is an INTEGER_CST,
in the second the loop has been vectorised out and the base is now a
variable.

This results in the analysis and build stage detecting the
STMT_VINFO_VEC_REDUCTION_TYPE as different types.

The easiest way to fix this is to only check for integer induction
conditions on the analysis stage.


gcc/
	PR tree-optimization/68413
	* tree-vect-loop.c (vectorizable_reduction): Only check for
	integer cond reduction on analysis stage.




Thanks,
Alan.


[-- Attachment #2: analysisonlycondcheck.patch --]
[-- Type: application/octet-stream, Size: 2930 bytes --]

diff --git a/gcc/testsuite/gcc.dg/vect/pr65947-1.c b/gcc/testsuite/gcc.dg/vect/pr65947-1.c
index 1e7a05dc8cc6f00fee265b9b8ad65beaa520f1e8..09fb6a5b446bac66e6509c704827231b10bec569 100644
--- a/gcc/testsuite/gcc.dg/vect/pr65947-1.c
+++ b/gcc/testsuite/gcc.dg/vect/pr65947-1.c
@@ -37,4 +37,4 @@ main (void)
 }
 
 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { xfail { ! vect_max_reduc } } } } */
-/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 4 "vect" { xfail { ! vect_max_reduc } } } } */
+/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 2 "vect" { xfail { ! vect_max_reduc } } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr65947-4.c b/gcc/testsuite/gcc.dg/vect/pr65947-4.c
index f4e7fdc97c89866b19838593cb84fc1754f87494..73ce780c08114b929f970afdc8d262efb8960562 100644
--- a/gcc/testsuite/gcc.dg/vect/pr65947-4.c
+++ b/gcc/testsuite/gcc.dg/vect/pr65947-4.c
@@ -37,5 +37,5 @@ main (void)
 }
 
 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { xfail { ! vect_max_reduc } } } } */
-/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 4 "vect" { xfail { ! vect_max_reduc } } } } */
+/* { dg-final { scan-tree-dump-times "condition expression based on integer induction." 2 "vect" { xfail { ! vect_max_reduc } } } } */
 
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 4630c86724e9f5df2b33eee4c60d3e7021b777b9..920dcd0ce5675753942d34db29c836e0e0737c26 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -5418,7 +5418,7 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
           reduc_index = i;
         }
 
-      if (i == 1 && code == COND_EXPR && dt == vect_induction_def
+      if (!vec_stmt && i == 1 && code == COND_EXPR && dt == vect_induction_def
 	  && is_nonwrapping_integer_induction (def_stmt, loop))
 	{
 	  if (dump_enabled_p ())
@@ -5452,14 +5452,20 @@ vectorizable_reduction (gimple *stmt, gimple_stmt_iterator *gsi,
       return false;
     }
 
-  gimple *tmp = vect_is_simple_reduction
-		  (loop_vinfo, reduc_def_stmt,
-		  !nested_cycle, &dummy, false,
-		  &STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info));
+  enum vect_reduction_type v_reduc_type;
+  gimple *tmp = vect_is_simple_reduction (loop_vinfo, reduc_def_stmt,
+					  !nested_cycle, &dummy, false,
+					  &v_reduc_type);
 
-  if (cond_expr_is_nonwrapping_integer_induction
-      && STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) == COND_REDUCTION)
-    STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = INTEGER_INDUC_COND_REDUCTION;
+  if (!vec_stmt)
+    {
+      if (cond_expr_is_nonwrapping_integer_induction
+	  && v_reduc_type == COND_REDUCTION)
+	STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info)
+		= INTEGER_INDUC_COND_REDUCTION;
+      else
+	STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info) = v_reduc_type;
+    }
 
   if (orig_stmt)
     gcc_assert (tmp == orig_stmt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-20 14:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20  9:24 [PATCH] PR tree-optimization/68413 : Only check for integer cond reduction on analysis stage Alan Hayward
2015-11-20 11:00 ` Richard Biener
2015-11-20 12:44   ` Alan Hayward
2015-11-20 13:47     ` Richard Biener
2015-11-20 14:21       ` Alan Hayward

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).