OSDN Git Service

PR tree-optimization/50414
authorirar <irar@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Sep 2011 11:36:15 +0000 (11:36 +0000)
committerirar <irar@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Sep 2011 11:36:15 +0000 (11:36 +0000)
        * tree-vect-slp.c (vect_get_constant_vectors): Handle MAX_EXPR
        and MIN_EXPR.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/no-scevccp-noreassoc-slp-reduc-7.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/vect/Ofast-pr50414.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/vect/vect.exp
gcc/tree-vect-slp.c

index be2acbe..aea0e31 100644 (file)
@@ -1,5 +1,11 @@
 2011-09-18  Ira Rosen  <ira.rosen@linaro.org>
 
+       PR tree-optimization/50414
+       * tree-vect-slp.c (vect_get_constant_vectors): Handle MAX_EXPR and
+       MIN_EXPR.
+
+2011-09-18  Ira Rosen  <ira.rosen@linaro.org>
+
        PR tree-optimization/50412
        * tree-vect-data-refs.c (vect_analyze_group_access): Fail for
        acceses that require epilogue loop if vectorizing outer loop.
index d375576..0a6fa97 100644 (file)
@@ -1,5 +1,12 @@
 2011-09-18  Ira Rosen  <ira.rosen@linaro.org>
 
+       PR tree-optimization/50414
+       * gfortran.dg/vect/Ofast-pr50414.f90: New.
+       * gfortran.dg/vect/vect.exp: Run Ofast-* tests with -Ofast.
+       * gcc.dg/vect/no-scevccp-noreassoc-slp-reduc-7.c: New.
+
+2011-09-18  Ira Rosen  <ira.rosen@linaro.org>
+
        PR tree-optimization/50412
        * gfortran.dg/vect/pr50412.f90: New.
 
diff --git a/gcc/testsuite/gcc.dg/vect/no-scevccp-noreassoc-slp-reduc-7.c b/gcc/testsuite/gcc.dg/vect/no-scevccp-noreassoc-slp-reduc-7.c
new file mode 100644 (file)
index 0000000..c268af7
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+#define MAX 121
+
+unsigned int ub[N] = {0,3,6,9,12,15,18,121,24,27,113,33,36,39,42,45};
+
+/* Vectorization of reduction using loop-aware SLP (with unrolling).  */
+
+__attribute__ ((noinline))
+int main1 (int n)
+{
+  int i;
+  unsigned int max = 50;
+
+  for (i = 0; i < n; i++) {
+    max = max < ub[2*i] ? ub[2*i] : max;
+    max = max < ub[2*i + 1] ? ub[2*i + 1] : max;
+  }
+
+  /* Check results:  */
+  if (max != MAX)
+    abort ();
+
+  return 0;
+}
+
+int main (void)
+{
+  check_vect ();
+
+  main1 (N/2);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_max } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail vect_no_int_max } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
diff --git a/gcc/testsuite/gfortran.dg/vect/Ofast-pr50414.f90 b/gcc/testsuite/gfortran.dg/vect/Ofast-pr50414.f90
new file mode 100644 (file)
index 0000000..c4a36db
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+
+      SUBROUTINE  SUB  (A,L,YMAX)
+      DIMENSION A(L)
+      YMA=A(1)
+      DO 2 I=1,L,2
+    2 YMA=MAX(YMA,A(I),A(I+1))
+      CALL PROUND(YMA)
+      END
+
+! { dg-final { cleanup-tree-dump "vect" } }
index 11bcecd..048e57d 100644 (file)
@@ -84,6 +84,12 @@ lappend DEFAULT_VECTCFLAGS "-O3"
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/O3-*.\[fF\]{,90,95,03,08} ]]  \
         "" $DEFAULT_VECTCFLAGS
 
+# With -Ofast
+set DEFAULT_VECTCFLAGS $SAVED_DEFAULT_VECTCFLAGS
+lappend DEFAULT_VECTCFLAGS "-Ofast"
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/Ofast-*.\[fF\]{,90,95,03,08} ]]  \
+        "" $DEFAULT_VECTCFLAGS
+
 # Clean up.
 set dg-do-what-default ${save-dg-do-what-default}
 
index 60bc475..669b2bb 100644 (file)
@@ -1902,6 +1902,8 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
   bool constant_p, is_store;
   tree neutral_op = NULL;
   enum tree_code code = gimple_assign_rhs_code (stmt);
+  gimple def_stmt;
+  struct loop *loop;
 
   if (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def)
     {
@@ -1943,8 +1945,16 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
             neutral_op = build_int_cst (TREE_TYPE (op), -1);
             break;
 
+          case MAX_EXPR:
+          case MIN_EXPR:
+            def_stmt = SSA_NAME_DEF_STMT (op);
+            loop = (gimple_bb (stmt))->loop_father;
+            neutral_op = PHI_ARG_DEF_FROM_EDGE (def_stmt,
+                                                loop_preheader_edge (loop));
+            break;
+
           default:
-             neutral_op = NULL;
+            neutral_op = NULL;
         }
     }
 
@@ -1997,8 +2007,8 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
 
           if (reduc_index != -1)
             {
-              struct loop *loop = (gimple_bb (stmt))->loop_father;
-              gimple def_stmt = SSA_NAME_DEF_STMT (op);
+              loop = (gimple_bb (stmt))->loop_father;
+              def_stmt = SSA_NAME_DEF_STMT (op);
 
               gcc_assert (loop);