]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add missing unit dependence vector in data dependence analysis
authorBin Cheng <bin.cheng@linux.alibaba.com>
Fri, 22 May 2020 03:42:11 +0000 (11:42 +0800)
committerBin Cheng <bin.cheng@linux.alibaba.com>
Fri, 22 May 2020 03:46:17 +0000 (11:46 +0800)
Current data dependence analysis misses unit distant vector if DRs in
DDR have the same invariant access functions.  This adds the vector as
the constant access function case.

Also fix typo in testcase.

Backport from master.

2020-05-13  Bin Cheng  <bin.cheng@linux.alibaba.com>

gcc/
PR tree-optimization/94969
* tree-data-ref.c (constant_access_functions): Rename to...
(invariant_access_functions): ...this.  Add parameter.  Check for
invariant access function, rather than constant.
(build_classic_dist_vector): Call above function.
* tree-loop-distribution.c (pg_add_dependence_edges): Add comment.

gcc/testsuite/
PR tree-optimization/94969
* gcc.dg/tree-ssa/pr94969.c: New test.

2020-05-13  Jakub Jelinek  <jakub@redhat.com>

gcc/testsuite/
PR tree-optimization/95110
* gcc.dg/tree-ssa/pr94969.c: Swap scan-tree-dump-not arguments.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr94969.c [new file with mode: 0644]
gcc/tree-data-ref.c
gcc/tree-loop-distribution.c

index 9b46fc9556f3db6ebd15648fe6938db51a785735..fb53bcc1934f5a12fda5ee7d750603eb64f18751 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-22  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       Backport from master
+       PR tree-optimization/94969
+       2020-05-13  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       * tree-data-ref.c (constant_access_functions): Rename to...
+       (invariant_access_functions): ...this.  Add parameter.  Check for
+       invariant access function, rather than constant.
+       (build_classic_dist_vector): Call above function.
+       * tree-loop-distribution.c (pg_add_dependence_edges): Add comment.
+
 2020-05-21  Martin Liska  <mliska@suse.cz>
 
        * common/config/aarch64/aarch64-common.c (aarch64_handle_option):
index 695ffa33298f86e77d2f4479a9ee1d7aeeb331f7..9ea89656bb4dccf652955975502012acbe110ff4 100644 (file)
@@ -1,3 +1,19 @@
+2020-05-22  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       Backport from master
+       PR tree-optimization/95110
+       2020-05-13  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/tree-ssa/pr94969.c: Swap scan-tree-dump-not arguments.
+
+2020-05-22  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       Backport from master
+       PR tree-optimization/94969
+       2020-05-13  Bin Cheng  <bin.cheng@linux.alibaba.com>
+
+       * gcc.dg/tree-ssa/pr94969.c: New test.
+
 2020-05-21  Martin Liska  <mliska@suse.cz>
 
        * gcc.target/aarch64/target_attr_20.c: New test.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94969.c b/gcc/testsuite/gcc.dg/tree-ssa/pr94969.c
new file mode 100644 (file)
index 0000000..f150461
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR tree-optimization/52267 */
+/* { dg-do run } */
+/* { dg-options "-O3 -fdump-tree-ldist-details" } */
+
+int a = 0, b = 0, c = 0;
+struct S {
+  signed m : 7;
+  signed e : 2;
+};
+struct S f[2] = {{0, 0}, {0, 0}};
+struct S g = {0, 0};
+
+void __attribute__((noinline))
+k()
+{
+  for (; c <= 1; c++) {
+    f[b] = g;
+    f[b].e ^= 1;
+  }
+}
+int main()
+{
+  k();
+  if (f[b].e != 1)
+    __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump-not "Loop 1 distributed: split to 3 loops" "ldist" } } */
index d00c1bd31e64ed72fde8bf4fa4cdf7663809dd11..efd720b9609837c91259da5ef312be67b957d7a0 100644 (file)
@@ -4369,17 +4369,19 @@ build_classic_dist_vector_1 (struct data_dependence_relation *ddr,
   return true;
 }
 
-/* Return true when the DDR contains only constant access functions.  */
+/* Return true when the DDR contains only invariant access functions wrto. loop
+   number LNUM.  */
 
 static bool
-constant_access_functions (const struct data_dependence_relation *ddr)
+invariant_access_functions (const struct data_dependence_relation *ddr,
+                           int lnum)
 {
   unsigned i;
   subscript *sub;
 
   FOR_EACH_VEC_ELT (DDR_SUBSCRIPTS (ddr), i, sub)
-    if (!evolution_function_is_constant_p (SUB_ACCESS_FN (sub, 0))
-       || !evolution_function_is_constant_p (SUB_ACCESS_FN (sub, 1)))
+    if (!evolution_function_is_invariant_p (SUB_ACCESS_FN (sub, 0), lnum)
+       || !evolution_function_is_invariant_p (SUB_ACCESS_FN (sub, 1), lnum))
       return false;
 
   return true;
@@ -4578,7 +4580,7 @@ build_classic_dist_vector (struct data_dependence_relation *ddr,
       dist_v = lambda_vector_new (DDR_NB_LOOPS (ddr));
       save_dist_v (ddr, dist_v);
 
-      if (constant_access_functions (ddr))
+      if (invariant_access_functions (ddr, loop_nest->num))
        add_distance_for_zero_overlaps (ddr);
 
       if (DDR_NB_LOOPS (ddr) > 1)
index 3e9b220ffb73fcb643847db045f82aac9738f68e..ad54c8dc33ae417a4b98c7c307e0a9eec1647149 100644 (file)
@@ -1949,7 +1949,8 @@ pg_add_dependence_edges (struct graph *rdg, int dir,
                this_dir = -this_dir;
 
              /* Known dependences can still be unordered througout the
-                iteration space, see gcc.dg/tree-ssa/ldist-16.c.  */
+                iteration space, see gcc.dg/tree-ssa/ldist-16.c and
+                gcc.dg/tree-ssa/pr94969.c.  */
              if (DDR_NUM_DIST_VECTS (ddr) != 1)
                this_dir = 2;
              /* If the overlap is exact preserve stmt order.  */