OSDN Git Service

2010-12-06 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Dec 2010 10:05:07 +0000 (10:05 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Dec 2010 10:05:07 +0000 (10:05 +0000)
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.

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

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 c3f25a5..ccb7019 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 01878fe..600655d 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 3aa77d6..2644c9e 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