]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/50328 (reduction with constant or invariant not vectorized)
authorRichard Guenther <rguenther@suse.de>
Fri, 9 Sep 2011 12:35:11 +0000 (12:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 9 Sep 2011 12:35:11 +0000 (12:35 +0000)
2011-09-09  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/50328
* tree-vect-loop.c (vect_is_simple_reduction_1): Allow one
constant or default-def operand.

* gcc.dg/vect/fast-math-vect-outer-7.c: New testcase.

From-SVN: r178728

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/fast-math-vect-outer-7.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 02b99c7c0f6554b638195e735c7df2c8b2b89006..87a114a1c7d40f9387cd7e863cedf7a3a4102925 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50328
+       * tree-vect-loop.c (vect_is_simple_reduction_1): Allow one
+       constant or default-def operand.
+
 2011-09-09  Richard Guenther  <rguenther@suse.de>
 
        * tree-ssa-pre.c (create_expression_by_pieces): Fold the
index f0a53831ca4c3348df70c51523e61b16ba8a892e..2ffd4f315f667212c853f2aadd21c99ffa5d8ef4 100644 (file)
@@ -1,3 +1,8 @@
+2011-09-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/50328
+       * gcc.dg/vect/fast-math-vect-outer-7.c: New testcase.
+
 2011-09-09  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/50333
diff --git a/gcc/testsuite/gcc.dg/vect/fast-math-vect-outer-7.c b/gcc/testsuite/gcc.dg/vect/fast-math-vect-outer-7.c
new file mode 100644 (file)
index 0000000..4dafa34
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+
+float dvec[256];
+
+void test1 (float x)
+{
+  long i, j;
+  for (i = 0; i < 256; ++i)
+    for (j = 0; j < 131072; ++j)
+      dvec[i] *= x;
+}
+
+void test2 (float x)
+{
+  long i, j;
+  for (i = 0; i < 256; ++i)
+    for (j = 0; j < 131072; ++j)
+      dvec[i] *= 1.001f;
+}
+
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 5c0b0a1c753f7533e73bb6a950f67294fa1d2f01..ba8878a86637bff9390243bfaa5bbcb9b9857f85 100644 (file)
@@ -2149,7 +2149,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
       op1 = gimple_assign_rhs1 (def_stmt);
       op2 = gimple_assign_rhs2 (def_stmt);
 
-      if (TREE_CODE (op1) != SSA_NAME || TREE_CODE (op2) != SSA_NAME)
+      if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
            report_vect_op (def_stmt, "reduction: uses not ssa_names: ");
@@ -2255,7 +2255,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
     def2 = SSA_NAME_DEF_STMT (op2);
 
   if (code != COND_EXPR
-      && (!def1 || !def2 || gimple_nop_p (def1) || gimple_nop_p (def2)))
+      && ((!def1 || gimple_nop_p (def1)) && (!def2 || gimple_nop_p (def2))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
        report_vect_op (def_stmt, "reduction: no defs for operands: ");
@@ -2268,6 +2268,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
 
   if (def2 && def2 == phi
       && (code == COND_EXPR
+         || !def1 || gimple_nop_p (def1)
           || (def1 && flow_bb_inside_loop_p (loop, gimple_bb (def1))
               && (is_gimple_assign (def1)
                  || is_gimple_call (def1)
@@ -2285,6 +2286,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
 
   if (def1 && def1 == phi
       && (code == COND_EXPR
+         || !def2 || gimple_nop_p (def2)
           || (def2 && flow_bb_inside_loop_p (loop, gimple_bb (def2))
              && (is_gimple_assign (def2)
                  || is_gimple_call (def2)