public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] Add missing unit dependence vector in data dependence analysis
Date: Thu, 17 Sep 2020 17:07:50 +0000 (GMT)	[thread overview]
Message-ID: <20200917170750.52CFB399D03B@sourceware.org> (raw)

https://gcc.gnu.org/g:000705acb47766b2f8b850a0e8a6a4c935a1730d

commit 000705acb47766b2f8b850a0e8a6a4c935a1730d
Author: Bin Cheng <bin.cheng@linux.alibaba.com>
Date:   Sat Jun 20 16:56:21 2020 +0800

    Add missing unit dependence vector in data dependence analysis
    
    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 commit: 287552950d56be47adb6b6bf2eae2d612233eaec
    and f6e1a4cd83190746b6544917f7526fa480ca5f18
    
    2020-06-20  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-06-20  Jakub Jelinek  <jakub@redhat.com>
    
    gcc/testsuite/
            PR tree-optimization/95110
            * gcc.dg/tree-ssa/pr94969.c: Swap scan-tree-dump-not arguments.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/pr94969.c | 28 ++++++++++++++++++++++++++++
 gcc/tree-data-ref.c                     | 12 +++++++-----
 gcc/tree-loop-distribution.c            |  3 ++-
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr94969.c b/gcc/testsuite/gcc.dg/tree-ssa/pr94969.c
new file mode 100644
index 00000000000..f15046122ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr94969.c
@@ -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" } } */
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index fc86bc25951..c90e862fb16 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -4342,17 +4342,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;
@@ -4551,7 +4553,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)
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 769523ba214..05766c7300d 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -1919,7 +1919,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.  */


                 reply	other threads:[~2020-09-17 17:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200917170750.52CFB399D03B@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).