OSDN Git Service

2011-09-09 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Sep 2011 12:35:11 +0000 (12:35 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Sep 2011 12:35:11 +0000 (12:35 +0000)
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.

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

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 02b99c7..87a114a 100644 (file)
@@ -1,5 +1,11 @@
 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
        last statement.
 
index f0a5383..2ffd4f3 100644 (file)
@@ -1,5 +1,10 @@
 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
        * gcc.dg/torture/pr50333.c: New testcase.
 
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 5c0b0a1..ba8878a 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)