]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/46785 (Doesn't vectorize reduction x += y*y)
authorRichard Guenther <rguenther@suse.de>
Mon, 6 Dec 2010 10:05:07 +0000 (10:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 6 Dec 2010 10:05:07 +0000 (10:05 +0000)
2010-12-06  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/46785
* tree-vect-loop.c (vect_is_simple_reduction_1): Also allow
call statements as operand definition.

* gcc.dg/vect/fast-math-vect-reduc-9.c: New testcase.

From-SVN: r167486

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

index c3f25a508d901c72d2db58563845afbfc528699c..ccb7019fa41b3f3116bd81c4e42ec7156ced0bcb 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-06  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46785
+       * tree-vect-loop.c (vect_is_simple_reduction_1): Also allow
+       call statements as operand definition.
+
 2010-12-06  Mingjie Xing  <mingjie.xing@gmail.com>
 
        * doc/tm.texi.in: Fix typo.
index 01878fe2c0a87dd98ebd57c065a50c072dd1f33f..600655d1d2cc5584cfecd30b6f30dc8c0b34d72b 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-06  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46785
+       * gcc.dg/vect/fast-math-vect-reduc-9.c: New testcase.
+
 2010-12-06  Dave Korn  <dave.korn.cygwin@gmail.com>
 
        * gcc.dg/pr46674.c (LABEL3): New macro definition.
diff --git a/gcc/testsuite/gcc.dg/vect/fast-math-vect-reduc-9.c b/gcc/testsuite/gcc.dg/vect/fast-math-vect-reduc-9.c
new file mode 100644 (file)
index 0000000..eb703f5
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-require-effective-target vect_float } */
+
+#include "tree-vect.h"
+
+float x[1024];
+float
+test (void)
+{
+  int i;
+  float gosa = 0.0;
+  for (i = 0; i < 1024; ++i)
+    {
+      float tem = x[i];
+      gosa += tem * tem;
+    }
+  return gosa;
+}
+
+int main (void)
+{
+  check_vect ();
+
+  if (test () != 0.0)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 3aa77d6ec1018687aafb70d47d4869525af4dcdb..2644c9e4349bed8d805de691edf5d87ac66b7ef1 100644 (file)
@@ -1970,6 +1970,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
       && (code == COND_EXPR
           || (def1 && flow_bb_inside_loop_p (loop, gimple_bb (def1))
               && (is_gimple_assign (def1)
+                 || is_gimple_call (def1)
                  || STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def1))
                       == vect_induction_def
                  || (gimple_code (def1) == GIMPLE_PHI
@@ -1985,6 +1986,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
           && (code == COND_EXPR
                || (def2 && flow_bb_inside_loop_p (loop, gimple_bb (def2))
                   && (is_gimple_assign (def2)
+                      || is_gimple_call (def2)
                       || STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def2))
                            == vect_induction_def
                       || (gimple_code (def2) == GIMPLE_PHI