]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/60382 (ICE on valid code at -O3 on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Tue, 13 May 2014 13:21:47 +0000 (13:21 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 13 May 2014 13:21:47 +0000 (13:21 +0000)
2014-05-13  Richard Biener  <rguenther@suse.de>

Backport from mainline
2014-03-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/60382
* tree-vect-loop.c (vect_is_simple_reduction_1): Do not consider
dead PHIs a reduction.

* gcc.dg/vect/pr60382.c: New testcase.

From-SVN: r210371

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr60382.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 848464fca3ff98567d02fd72f3c95a12352c946a..8cc35b37df590d189d0863e9b4120589af39d236 100644 (file)
@@ -1,3 +1,12 @@
+2014-05-13  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-03-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60382
+       * tree-vect-loop.c (vect_is_simple_reduction_1): Do not consider
+       dead PHIs a reduction.
+
 2014-05-09  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2014-05-09 trunk r210267
index baca8cd6d590d3ae84a5714c26cf35a7aa89b739..bf2dd75dc2e835d74575c26b180203d131144976 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-13  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-03-04  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60382
+       * gcc.dg/vect/pr60382.c: New testcase.
+
 2014-05-09  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2014-05-09 trunk r210267
diff --git a/gcc/testsuite/gcc.dg/vect/pr60382.c b/gcc/testsuite/gcc.dg/vect/pr60382.c
new file mode 100644 (file)
index 0000000..a28c631
--- /dev/null
@@ -0,0 +1,32 @@
+#include "tree-vect.h"
+
+int a, b, c, e, f;
+
+void
+foo ()
+{
+  for (b = 0; b < 3; b++)
+    if (e)
+      {
+       for (c = 0; c < 4; c++)
+         {
+           if (b)
+             continue;
+           f = 1;
+           for (a = 0; a < 2; a++)
+             f |= 1;
+         }
+       for (;;)
+         ;
+      }
+}
+
+int
+main ()
+{
+  check_vect ();
+  foo ();
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
index c73d758570fb1f5c51987ae4e209b7da68ec6f01..964e5dd2c887b2e4335504bfae8ea3b8886fe4a4 100644 (file)
@@ -2009,6 +2009,12 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
               || (!check_reduction && flow_loop_nested_p (vect_loop, loop)));
 
   name = PHI_RESULT (phi);
+  /* ???  If there are no uses of the PHI result the inner loop reduction
+     won't be detected as possibly double-reduction by vectorizable_reduction
+     because that tries to walk the PHI arg from the preheader edge which
+     can be constant.  See PR60382.  */
+  if (has_zero_uses (name))
+    return NULL;
   nloop_uses = 0;
   FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
     {