This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR81500
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 21 Jul 2017 13:30:53 +0200 (CEST)
- Subject: [PATCH] Fix PR81500
- Authentication-results: sourceware.org; auth=none
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2017-06-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/81500
* tree-vect-loop.c (vect_is_simple_reduction): Properly fail if
we didn't identify a reduction path.
* gcc.dg/torture/pr81500.c: New testcase.
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c (revision 250386)
+++ gcc/tree-vect-loop.c (working copy)
@@ -3243,7 +3243,7 @@ pop:
}
/* Check whether the reduction path detected is valid. */
- bool fail = false;
+ bool fail = path.length () == 0;
bool neg = false;
for (unsigned i = 1; i < path.length (); ++i)
{
@@ -3276,9 +3276,7 @@ pop:
if (dump_enabled_p ())
{
- report_vect_op (MSG_MISSED_OPTIMIZATION,
- SSA_NAME_DEF_STMT
- (USE_FROM_PTR (path[path.length ()-1].second)),
+ report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
"reduction: unknown pattern: ");
}
Index: gcc/testsuite/gcc.dg/torture/pr81500.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr81500.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr81500.c (working copy)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+typedef int a;
+void c(int *b)
+{
+ int d;
+ a e, f, *g, *h = b;
+ for (; d; d--) {
+ f = *g & 1;
+ *h-- = *g-- | e;
+ e = f;
+ }
+}