OSDN Git Service

PR tree-optimization/50819
authorirar <irar@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 Oct 2011 12:13:49 +0000 (12:13 +0000)
committerirar <irar@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 Oct 2011 12:13:49 +0000 (12:13 +0000)
        * tree-vectorizer.h (vect_analyze_data_ref_dependences): Remove
        the last argument.
        * tree-vect-loop.c (vect_analyze_loop_2): Update call to
        vect_analyze_data_ref_dependences.
        * tree-vect-data-refs.c (vect_analyze_data_ref_dependence):
        Remove the last argument.  Check load-after-store dependence
        for unknown dependencies in basic blocks.
        (vect_analyze_data_ref_dependences): Update call to
        vect_analyze_data_ref_dependences.
        * tree-vect-patterns.c (vect_recog_widen_shift_pattern): Fix
        typo.
        * tree-vect-slp.c (vect_bb_vectorizable_with_dependencies):
        Remove.
        (vect_slp_analyze_bb_1): Update call to
        vect_analyze_data_ref_dependences.  Don't call
        vect_bb_vectorizable_with_dependencies.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/vect/slp-pr50819.cc [new file with mode: 0644]
gcc/testsuite/g++.dg/vect/vect.exp
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop.c
gcc/tree-vect-patterns.c
gcc/tree-vect-slp.c
gcc/tree-vectorizer.h

index 269c1cd..fac9fa9 100644 (file)
@@ -1,3 +1,21 @@
+2011-10-23  Ira Rosen  <ira.rosen@linaro.org>
+
+       PR tree-optimization/50819
+       * tree-vectorizer.h (vect_analyze_data_ref_dependences): Remove
+       the last argument.
+       * tree-vect-loop.c (vect_analyze_loop_2): Update call to
+       vect_analyze_data_ref_dependences.
+       * tree-vect-data-refs.c (vect_analyze_data_ref_dependence): Remove
+       the last argument.  Check load-after-store dependence for unknown
+       dependencies in basic blocks.
+       (vect_analyze_data_ref_dependences): Update call to
+       vect_analyze_data_ref_dependences.
+       * tree-vect-patterns.c (vect_recog_widen_shift_pattern): Fix typo.
+       * tree-vect-slp.c (vect_bb_vectorizable_with_dependencies): Remove.
+       (vect_slp_analyze_bb_1): Update call to
+       vect_analyze_data_ref_dependences.  Don't call
+       vect_bb_vectorizable_with_dependencies.
+
 2011-10-22  David S. Miller  <davem@davemloft.net>
 
        * config/sparc/sparc.h (SECONDARY_INPUT_RELOAD_CLASS,
index 71aa33d..16b6f6f 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-23  Ira Rosen  <ira.rosen@linaro.org>
+
+       PR tree-optimization/50819
+       * g++.dg/vect/vect.exp: Set target dependent flags for slp-* tests.
+       * g++.dg/vect/slp-pr50819.cc: New test.
+
 2011-10-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/45385
diff --git a/gcc/testsuite/g++.dg/vect/slp-pr50819.cc b/gcc/testsuite/g++.dg/vect/slp-pr50819.cc
new file mode 100644 (file)
index 0000000..402218b
--- /dev/null
@@ -0,0 +1,53 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+
+typedef float Value;
+
+struct LorentzVector
+{
+
+  LorentzVector(Value x=0, Value  y=0, Value  z=0, Value  t=0) :
+theX(x),theY(y),theZ(z),theT(t){}
+  LorentzVector & operator+=(const LorentzVector & a) {
+    theX += a.theX;
+    theY += a.theY;
+    theZ += a.theZ;
+    theT += a.theT;
+    return *this;
+  }
+
+  Value theX;
+  Value theY;
+  Value theZ;
+  Value theT;
+}  __attribute__ ((aligned(16)));
+
+inline LorentzVector
+operator+(LorentzVector const & a, LorentzVector const & b) {
+  return
+LorentzVector(a.theX+b.theX,a.theY+b.theY,a.theZ+b.theZ,a.theT+b.theT);
+}
+
+inline LorentzVector
+operator*(LorentzVector const & a, Value s) {
+    return LorentzVector(a.theX*s,a.theY*s,a.theZ*s,a.theT*s);
+}
+
+inline LorentzVector
+operator*(Value s, LorentzVector const & a) {
+  return a*s;
+}
+
+
+void sum1(LorentzVector & res, Value s, LorentzVector const & v1, LorentzVector
+const & v2) {
+  res += s*(v1+v2);
+}
+
+void sum2(LorentzVector & res, Value s, LorentzVector const & v1, LorentzVector
+const & v2) {
+  res = res + s*(v1+v2);
+}
+
+/* { dg-final { scan-tree-dump-times "basic block vectorized using SLP" 2 "slp" } } */
+/* { dg-final { cleanup-tree-dump "slp" } } */
index ac22f4b..76bd99a 100644 (file)
@@ -42,12 +42,6 @@ set DEFAULT_VECTCFLAGS ""
 # These flags are used for all targets.
 lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fno-vect-cost-model"
 
-set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS
-
-lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details"
-lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
-
-
 # Skip these tests for targets that do not support generating vector
 # code.  Set additional target-dependent vector flags, which can be
 # overridden by using dg-options in individual tests.
@@ -55,6 +49,11 @@ if ![check_vect_support_and_set_flags] {
     return
 }
 
+set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS
+
+lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details"
+lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details"
+
 # Initialize `dg'.
 dg-init
 
index a9504cd..3634e5e 100644 (file)
@@ -555,8 +555,7 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_vec_info loop_vinfo)
 
 static bool
 vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
-                                  loop_vec_info loop_vinfo, int *max_vf,
-                                  bool *data_dependence_in_bb)
+                                  loop_vec_info loop_vinfo, int *max_vf)
 {
   unsigned int i;
   struct loop *loop = NULL;
@@ -587,6 +586,8 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 
   if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
     {
+      gimple earlier_stmt;
+
       if (loop_vinfo)
         {
           if (vect_print_dump_info (REPORT_DR_DETAILS))
@@ -624,10 +625,11 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
       if (DR_IS_WRITE (dra) && DR_IS_WRITE (drb))
         return true;
 
-      /* We deal with read-write dependencies in basic blocks later (by
-         verifying that all the loads in the basic block are before all the
-         stores).  */
-      *data_dependence_in_bb = true;
+      /* Check that it's not a load-after-store dependence.  */
+      earlier_stmt = get_earlier_stmt (DR_STMT (dra), DR_STMT (drb));
+      if (DR_IS_WRITE (STMT_VINFO_DATA_REF (vinfo_for_stmt (earlier_stmt))))
+        return true;
+
       return false;
     }
 
@@ -753,8 +755,7 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
 
 bool
 vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo,
-                                   bb_vec_info bb_vinfo, int *max_vf,
-                                   bool *data_dependence_in_bb)
+                                   bb_vec_info bb_vinfo, int *max_vf)
 {
   unsigned int i;
   VEC (ddr_p, heap) *ddrs = NULL;
@@ -769,8 +770,7 @@ vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo,
     ddrs = BB_VINFO_DDRS (bb_vinfo);
 
   FOR_EACH_VEC_ELT (ddr_p, ddrs, i, ddr)
-    if (vect_analyze_data_ref_dependence (ddr, loop_vinfo, max_vf,
-                                         data_dependence_in_bb))
+    if (vect_analyze_data_ref_dependence (ddr, loop_vinfo, max_vf))
       return false;
 
   return true;
index ba8878a..3ef407e 100644 (file)
@@ -1473,7 +1473,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
 static bool
 vect_analyze_loop_2 (loop_vec_info loop_vinfo)
 {
-  bool ok, dummy, slp = false;
+  bool ok, slp = false;
   int max_vf = MAX_VECTORIZATION_FACTOR;
   int min_vf = 2;
 
@@ -1514,7 +1514,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
      the dependences.
      FORNOW: fail at the first data dependence that we encounter.  */
 
-  ok = vect_analyze_data_ref_dependences (loop_vinfo, NULL, &max_vf, &dummy);
+  ok = vect_analyze_data_ref_dependences (loop_vinfo, NULL, &max_vf);
   if (!ok
       || max_vf < min_vf)
     {
index 94ab9b7..94e2801 100644 (file)
@@ -1225,7 +1225,7 @@ vect_recog_over_widening_pattern (VEC (gimple, heap) **stmts,
 
   where type 'TYPE' is at least double the size of type 'type'.
 
-  Also detect unsgigned cases:
+  Also detect unsigned cases:
 
   unsigned type a_t;
   unsigned TYPE u_res_T;
index f131f1e..f75817b 100644 (file)
@@ -1706,43 +1706,6 @@ vect_slp_analyze_operations (bb_vec_info bb_vinfo)
   return true;
 }
 
-/* Check if loads and stores are mixed in the basic block (in that
-   case if we are not sure that the accesses differ, we can't vectorize the
-   basic block).  Also return FALSE in case that there is statement marked as
-   not vectorizable.  */
-
-static bool
-vect_bb_vectorizable_with_dependencies (bb_vec_info bb_vinfo)
-{
-  basic_block bb = BB_VINFO_BB (bb_vinfo);
-  gimple_stmt_iterator si;
-  bool detected_store = false;
-  gimple stmt;
-  struct data_reference *dr;
-
-  for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
-    {
-      stmt = gsi_stmt (si);
-
-      /* We can't allow not analyzed statements, since they may contain data
-         accesses.  */ 
-      if (!STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (stmt)))
-        return false;
-
-      if (!STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt)))
-        continue;
-
-      dr = STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt));
-      if (DR_IS_READ (dr) && detected_store)
-        return false;
-
-      if (!DR_IS_READ (dr))
-        detected_store = true;
-    }
-
-  return true;
-}
-
 /* Check if vectorization of the basic block is profitable.  */
 
 static bool
@@ -1823,7 +1786,6 @@ vect_slp_analyze_bb_1 (basic_block bb)
   int i;
   int min_vf = 2;
   int max_vf = MAX_VECTORIZATION_FACTOR;
-  bool data_dependence_in_bb = false;
 
   bb_vinfo = new_bb_vec_info (bb);
   if (!bb_vinfo)
@@ -1850,11 +1812,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
       return NULL;
     }
 
-   if (!vect_analyze_data_ref_dependences (NULL, bb_vinfo, &max_vf, 
-                                           &data_dependence_in_bb)
-       || min_vf > max_vf
-       || (data_dependence_in_bb 
-           && !vect_bb_vectorizable_with_dependencies (bb_vinfo)))
+   if (!vect_analyze_data_ref_dependences (NULL, bb_vinfo, &max_vf)
+       || min_vf > max_vf)
      {
        if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
         fprintf (vect_dump, "not vectorized: unhandled data dependence "
index c27e76c..b0142e2 100644 (file)
@@ -832,7 +832,7 @@ extern enum dr_alignment_support vect_supportable_dr_alignment
 extern tree vect_get_smallest_scalar_type (gimple, HOST_WIDE_INT *,
                                            HOST_WIDE_INT *);
 extern bool vect_analyze_data_ref_dependences (loop_vec_info, bb_vec_info,
-                                              int *, bool *);
+                                              int *);
 extern bool vect_enhance_data_refs_alignment (loop_vec_info);
 extern bool vect_analyze_data_refs_alignment (loop_vec_info, bb_vec_info);
 extern bool vect_verify_datarefs_alignment (loop_vec_info, bb_vec_info);