]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/56933 (Vectorizer missing read-write dependency for interleav...
authorRichard Biener <rguenther@suse.de>
Mon, 15 Apr 2013 14:08:41 +0000 (14:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 15 Apr 2013 14:08:41 +0000 (14:08 +0000)
2013-04-15  Richard Biener  <rguenther@suse.de>

PR tree-optimization/56933
* tree-vectorizer.h (struct _stmt_vec_info): Remove read_write_dep
member.
(GROUP_READ_WRITE_DEPENDENCE): Remove.
(STMT_VINFO_GROUP_READ_WRITE_DEPENDENCE): Likewise.
* tree-vect-data-refs.c (vect_analyze_group_access): Move
dependence check ...
vect_analyze_data_ref_dependence (vect_analyze_data_ref_dependence):
... here.
* tree-vect-stmts.c (new_stmt_vec_info): Do not initialize
GROUP_READ_WRITE_DEPENDENCE.

* gcc.dg/vect/pr56933.c: New testcase.

From-SVN: r197972

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr56933.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.h

index fd1731e7e8d202e3444d6ef74211d2ba0c5e2620..db1b37325b45a674f1c851bb59b00727b7b6f6f8 100644 (file)
@@ -1,3 +1,17 @@
+2013-04-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56933
+       * tree-vectorizer.h (struct _stmt_vec_info): Remove read_write_dep
+       member.
+       (GROUP_READ_WRITE_DEPENDENCE): Remove.
+       (STMT_VINFO_GROUP_READ_WRITE_DEPENDENCE): Likewise.
+       * tree-vect-data-refs.c (vect_analyze_group_access): Move
+       dependence check ...
+       vect_analyze_data_ref_dependence (vect_analyze_data_ref_dependence):
+       ... here.
+       * tree-vect-stmts.c (new_stmt_vec_info): Do not initialize
+       GROUP_READ_WRITE_DEPENDENCE.
+
 2013-04-15  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
        * emit-rtl.c (reset_all_used_flags): New function.
index efc3ded90990603f11b7686ae32e3c1180b716b5..46135933624725768fbb9cdb20ea6ec35e5b8d03 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-15  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/56933
+       * gcc.dg/vect/pr56933.c: New testcase.
+
 2013-04-15  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * gcc.target/arm/anddi3-opt.c: New test.
diff --git a/gcc/testsuite/gcc.dg/vect/pr56933.c b/gcc/testsuite/gcc.dg/vect/pr56933.c
new file mode 100644 (file)
index 0000000..93a7da2
--- /dev/null
@@ -0,0 +1,40 @@
+/* { dg-do run } */
+
+extern void abort (void);
+void __attribute__((noinline,noclone))
+foo (double *b, double *d, double *f)
+{
+  int i;
+  for (i = 0; i < 1024; i++)
+    {
+      d[2*i] = 2. * d[2*i];
+      d[2*i+1] = 4. * d[2*i+1];
+      b[i] = d[2*i] - 1.;
+      f[i] = d[2*i+1] + 2.;
+    }
+}
+int main()
+{
+  double b[1024], d[2*1024], f[1024];
+  int i;
+  for (i = 0; i < 2*1024; i++)
+    d[i] = 1.;
+  foo (b, d, f);
+  for (i = 0; i < 1024; i+= 2)
+    {
+      if (d[2*i] != 2.)
+       abort ();
+      if (d[2*i+1] != 4.)
+       abort ();
+    }
+  for (i = 0; i < 1024; i++)
+    {
+      if (b[i] != 1.)
+       abort ();
+      if (f[i] != 6.)
+       abort ();
+    }
+  return 0;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 64f2a8b6d9e29dfaf67e7b9e1f0c1960b710e5b5..1fe5047c70b70eb72a9f61003b3cef426b596d63 100644 (file)
@@ -341,14 +341,34 @@ vect_analyze_data_ref_dependence (struct data_dependence_relation *ddr,
              dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
            }
 
-          /* For interleaving, mark that there is a read-write dependency if
-             necessary.  We check before that one of the data-refs is store.  */
-          if (DR_IS_READ (dra))
-            GROUP_READ_WRITE_DEPENDENCE (stmtinfo_a) = true;
-         else
-            {
-              if (DR_IS_READ (drb))
-                GROUP_READ_WRITE_DEPENDENCE (stmtinfo_b) = true;
+         /* When we perform grouped accesses and perform implicit CSE
+            by detecting equal accesses and doing disambiguation with
+            runtime alias tests like for
+               .. = a[i];
+               .. = a[i+1];
+               a[i] = ..;
+               a[i+1] = ..;
+               *p = ..;
+               .. = a[i];
+               .. = a[i+1];
+            where we will end up loading { a[i], a[i+1] } once, make
+            sure that inserting group loads before the first load and
+            stores after the last store will do the right thing.  */
+         if ((STMT_VINFO_GROUPED_ACCESS (stmtinfo_a)
+              && GROUP_SAME_DR_STMT (stmtinfo_a))
+             || (STMT_VINFO_GROUPED_ACCESS (stmtinfo_b)
+                 && GROUP_SAME_DR_STMT (stmtinfo_b)))
+           {
+             gimple earlier_stmt;
+             earlier_stmt = get_earlier_stmt (DR_STMT (dra), DR_STMT (drb));
+             if (DR_IS_WRITE
+                   (STMT_VINFO_DATA_REF (vinfo_for_stmt (earlier_stmt))))
+               {
+                 if (dump_enabled_p ())
+                   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                    "READ_WRITE dependence in interleaving.");
+                 return true;
+               }
            }
 
          continue;
@@ -2097,17 +2117,6 @@ vect_analyze_group_access (struct data_reference *dr)
                   return false;
                 }
 
-              /* Check that there is no load-store dependencies for this loads
-                 to prevent a case of load-store-load to the same location.  */
-              if (GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (next))
-                  || GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (prev)))
-                {
-                  if (dump_enabled_p ())
-                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
-                                     "READ_WRITE dependence in interleaving.");
-                  return false;
-                }
-
               /* For load use the same data-ref load.  */
               GROUP_SAME_DR_STMT (vinfo_for_stmt (next)) = prev;
 
index 3590e3960d2a7da74ce98fc6f0691b3d7d3b5bf2..bdd4d6402ee66d729ee8448a03f89fe441d65207 100644 (file)
@@ -5962,7 +5962,6 @@ new_stmt_vec_info (gimple stmt, loop_vec_info loop_vinfo,
   GROUP_STORE_COUNT (res) = 0;
   GROUP_GAP (res) = 0;
   GROUP_SAME_DR_STMT (res) = NULL;
-  GROUP_READ_WRITE_DEPENDENCE (res) = false;
 
   return res;
 }
index 0f1a02a2e373a3410f51a0cd9b51b388eccb1140..807114995203bc53e8d183abde252a71f37efeb2 100644 (file)
@@ -460,10 +460,6 @@ typedef struct _stmt_vec_info {
   /* Stmt is part of some pattern (computation idiom)  */
   bool in_pattern_p;
 
-  /* For loads only, if there is a store with the same location, this field is
-     TRUE.  */
-  bool read_write_dep;
-
   /* The stmt to which this info struct refers to.  */
   gimple stmt;
 
@@ -589,7 +585,6 @@ typedef struct _stmt_vec_info {
 #define STMT_VINFO_GROUP_STORE_COUNT(S)    (S)->store_count
 #define STMT_VINFO_GROUP_GAP(S)            (S)->gap
 #define STMT_VINFO_GROUP_SAME_DR_STMT(S)   (S)->same_dr_stmt
-#define STMT_VINFO_GROUP_READ_WRITE_DEPENDENCE(S)  (S)->read_write_dep
 #define STMT_VINFO_GROUPED_ACCESS(S)      ((S)->first_element != NULL && (S)->data_ref_info)
 #define STMT_VINFO_LOOP_PHI_EVOLUTION_PART(S) (S)->loop_phi_evolution_part
 
@@ -599,7 +594,6 @@ typedef struct _stmt_vec_info {
 #define GROUP_STORE_COUNT(S)            (S)->store_count
 #define GROUP_GAP(S)                    (S)->gap
 #define GROUP_SAME_DR_STMT(S)           (S)->same_dr_stmt
-#define GROUP_READ_WRITE_DEPENDENCE(S)  (S)->read_write_dep
 
 #define STMT_VINFO_RELEVANT_P(S)          ((S)->relevant != vect_unused_in_scope)