re PR tree-optimization/47139 (ice in process_use, at tree-vect-stmts.c:290)
authorIra Rosen <irar@il.ibm.com>
Thu, 6 Jan 2011 07:34:24 +0000 (07:34 +0000)
committerIra Rosen <irar@gcc.gnu.org>
Thu, 6 Jan 2011 07:34:24 +0000 (07:34 +0000)
        PR tree-optimization/47139
        * tree-vect-loop.c (vect_is_simple_reduction_1): Check that
        only the last reduction value is used outside the loop. Update
        documentation.

From-SVN: r168535

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

index f23274bcac4da468a16cec79f2f7b04424236860..33945a3b518eadcdc9eb04970c7a0c82a0289add 100644 (file)
@@ -1,3 +1,10 @@
+2011-01-06  Ira Rosen  <irar@il.ibm.com>
+
+       PR tree-optimization/47139
+       * tree-vect-loop.c (vect_is_simple_reduction_1): Check that
+       only the last reduction value is used outside the loop.  Update
+       documentation.
+
 2011-01-05  Joseph Myers  <joseph@codesourcery.com>
 
        * config/rtems.opt: New.
index ea5cac790bf09ab208870eec65672a4ab64ce75b..564be0f86a6b23e6a8a36174cef07cfadd361089 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-06  Ira Rosen  <irar@il.ibm.com>
+
+       PR tree-optimization/47139
+       * gcc.dg/vect/pr47139.c: New test.
+
 2011-01-05  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/47180
diff --git a/gcc/testsuite/gcc.dg/vect/pr47139.c b/gcc/testsuite/gcc.dg/vect/pr47139.c
new file mode 100644 (file)
index 0000000..9e9c751
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+int d;
+
+void
+foo ()
+{
+  int a = 0;
+  unsigned char b;
+  for (b = 1; b; b++)
+    {
+      d = a;
+      a |= b;
+    }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
index 1dc4ec0fde950112c8c3583f0523295819060f5a..d474688ebecba312228d4c2ac29e4f4201cbf68a 100644 (file)
@@ -1649,9 +1649,10 @@ report_vect_op (gimple stmt, const char *msg)
    1. operation is commutative and associative and it is safe to
       change the order of the computation (if CHECK_REDUCTION is true)
    2. no uses for a2 in the loop (a2 is used out of the loop)
-   3. no uses of a1 in the loop besides the reduction operation.
+   3. no uses of a1 in the loop besides the reduction operation
+   4. no uses of a1 outside the loop.
 
-   Condition 1 is tested here.
+   Conditions 1,4 are tested here.
    Conditions 2,3 are tested in vect_mark_stmts_to_be_vectorized.
 
    (2) Detect a cross-iteration def-use cycle in nested loops, i.e.,
@@ -1702,8 +1703,16 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
       gimple use_stmt = USE_STMT (use_p);
       if (is_gimple_debug (use_stmt))
        continue;
-      if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))
-         && vinfo_for_stmt (use_stmt)
+
+      if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
+        {
+          if (vect_print_dump_info (REPORT_DETAILS))
+            fprintf (vect_dump, "intermediate value used outside loop.");
+
+          return NULL;
+        }
+
+      if (vinfo_for_stmt (use_stmt)
          && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt)))
         nloop_uses++;
       if (nloop_uses > 1)