]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2016-01-14 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Jan 2016 15:13:19 +0000 (15:13 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Jan 2016 15:13:19 +0000 (15:13 +0000)
PR tree-optimization/68060
* tree-vect-loop.c (vect_is_simple_reduction): Check the
outer loop reduction is only used in the inner loop before
detecting a double reduction.

* gcc.dg/torture/pr68060-1.c: New testcase.
* gcc.dg/torture/pr68060-2.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232367 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr68060-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr68060-2.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index fe9a60a0c77926b300b2c348177e7a9863d76e74..77e379cfa022c8ff42749c2e90b74adb7a3aa995 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/68060
+       * tree-vect-loop.c (vect_is_simple_reduction): Check the
+       outer loop reduction is only used in the inner loop before
+       detecting a double reduction.
+
 2016-01-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/68269
index ef76d22a56e2b7b8e6cfd55ab3c513c54bababb0..e10a21433f41a48741a74728fb413c5fa8ab5468 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/68060
+       * gcc.dg/torture/pr68060-1.c: New testcase.
+       * gcc.dg/torture/pr68060-2.c: Likewise.
+
 2016-01-14  Nick Clifton  <nickc@redhat.com>
 
        * lib/target-supports.exp
diff --git a/gcc/testsuite/gcc.dg/torture/pr68060-1.c b/gcc/testsuite/gcc.dg/torture/pr68060-1.c
new file mode 100644 (file)
index 0000000..8830d87
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+int a, b, c;
+
+int
+main ()
+{
+  for (; c; c++)
+    for (a = 0; a < 4; a++)
+      {
+       c &= 5;
+       for (b = 0; b < 2; b++)
+         c |= 1;
+      }
+  return 0; 
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr68060-2.c b/gcc/testsuite/gcc.dg/torture/pr68060-2.c
new file mode 100644 (file)
index 0000000..974ddc7
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+void fn2 ();
+
+int a, b, c;
+
+void fn1()
+{
+  for (;;) {
+      int *d;
+      fn2();
+      c = 0;
+      for (; c <= 3; c++) {
+         *d ^= 9;
+         b = 0;
+         for (; b <= 3; b++)
+           *d ^= a;
+      }
+  }
+}
index 0933e7eb770550ec90dd2898503c7c077954b993..b095f8fbafb8540ea963b4f604f8c083c30d58f1 100644 (file)
@@ -2591,7 +2591,7 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
   struct loop *vect_loop = LOOP_VINFO_LOOP (loop_info);
   edge latch_e = loop_latch_edge (loop);
   tree loop_arg = PHI_ARG_DEF_FROM_EDGE (phi, latch_e);
-  gimple *def_stmt, *def1 = NULL, *def2 = NULL;
+  gimple *def_stmt, *def1 = NULL, *def2 = NULL, *phi_use_stmt = NULL;
   enum tree_code orig_code, code;
   tree op1, op2, op3 = NULL_TREE, op4 = NULL_TREE;
   tree type;
@@ -2640,6 +2640,8 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
                             "reduction used in loop.\n");
           return NULL;
         }
+
+      phi_use_stmt = use_stmt;
     }
 
   if (TREE_CODE (loop_arg) != SSA_NAME)
@@ -2722,7 +2724,8 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
          && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
           && loop->inner
           && flow_bb_inside_loop_p (loop->inner, gimple_bb (def1))
-          && is_gimple_assign (def1))
+          && is_gimple_assign (def1)
+         && flow_bb_inside_loop_p (loop->inner, gimple_bb (phi_use_stmt)))
         {
           if (dump_enabled_p ())
             report_vect_op (MSG_NOTE, def_stmt,