This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Implement cond and induction cond reduction w/o REDUC_MAX_EXPR
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: alan dot hayward at arm dot com
- Date: Thu, 22 Jun 2017 10:13:24 +0200 (CEST)
- Subject: Re: [PATCH] Implement cond and induction cond reduction w/o REDUC_MAX_EXPR
- Authentication-results: sourceware.org; auth=none
- References: <alpine.LSU.2.20.1706211547590.22867@zhemvz.fhfr.qr>
On Wed, 21 Jun 2017, Richard Biener wrote:
>
> During my attempt to refactor reduction vectorization I ran across
> the special casing of inital values for INTEGER_INDUC_COND_REDUCTION
> and tried to see what it is about. So I ended up implementing
> cond reduction support for targets w/o REDUC_MAX_EXPR by simply
> doing the reduction in scalar code -- while that results in an
> expensive epilogue the vector loop should be reasonably fast.
>
> I still didn't run into any exec FAILs in vect.exp with removing
> the INTEGER_INDUC_COND_REDUCTION special case thus the following
> patch.
>
> Alan -- is there a testcase (maybe full bootstrap & regtest will
> unconver one) that shows how this is necessary?
Testing has some fallout and I discovered what this special-case is
about. I'll commit the below testcase to exercise the case.
Richard.
2017-06-22 Richard Biener <rguenther@suse.de>
* gcc.dg/vect/pr65947-14.c: New testcase.
Index: gcc/testsuite/gcc.dg/vect/pr65947-14.c
===================================================================
--- gcc/testsuite/gcc.dg/vect/pr65947-14.c (nonexistent)
+++ gcc/testsuite/gcc.dg/vect/pr65947-14.c (working copy)
@@ -0,0 +1,44 @@
+/* { dg-require-effective-target vect_condition } */
+
+#include "tree-vect.h"
+
+extern void abort (void) __attribute__ ((noreturn));
+
+#define N 27
+
+/* Condition reduction with matches only in even lanes at runtime. */
+
+int
+condition_reduction (int *a, int min_v)
+{
+ int last = N + 96;
+
+ for (int i = 0; i < N; i++)
+ if (a[i] > min_v)
+ last = i;
+
+ return last;
+}
+
+int
+main (void)
+{
+ int a[N] = {
+ 47, 12, 13, 14, 15, 16, 17, 18, 19, 20,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 21, 22, 23, 24, 25, 26, 27
+ };
+
+ check_vect ();
+
+ int ret = condition_reduction (a, 46);
+
+ /* loop should have found a value of 0, not default N + 96. */
+ if (ret != 0)
+ abort ();
+
+ return 0;
+}
+
+/* { 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" } } */