public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/99956] loop interchange fails when altering bwaves inner loop
Date: Wed, 07 Apr 2021 12:46:25 +0000	[thread overview]
Message-ID: <bug-99956-4-DWH4aCV5AE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99956-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99956

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Sth as simple (and brute-force) as the following fixes this.  Somehow SCEV
must already know the "point of failure" though and eventually always
instantiating from loop to loop_nest in steps might be more efficient than
trying all possibilities on failure (or maybe we should do that on failure).

diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index f45b9364644..215587a8406 100644
--- a/gcc/gimple-loop-interchange.cc
+++ b/gcc/gimple-loop-interchange.cc
@@ -1320,7 +1320,14 @@ compute_access_stride (class loop *loop_nest, class loop
*loop,
     }
   tree scev_base = build_fold_addr_expr (ref);
   tree scev = analyze_scalar_evolution (loop, scev_base);
-  scev = instantiate_scev (loop_preheader_edge (loop_nest), loop, scev);
+  tree orig_scev = scev;
+  scev = instantiate_scev (loop_preheader_edge (loop_nest), loop, orig_scev);
+  while (chrec_contains_undetermined (scev) && loop_nest != loop)
+    {
+      loop_nest = loop_nest->inner;
+      scev = instantiate_scev (loop_preheader_edge (loop_nest),
+                              loop, orig_scev);
+    }
   if (! chrec_contains_undetermined (scev))
     {
       tree sl = scev;

  parent reply	other threads:[~2021-04-07 12:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 12:21 [Bug tree-optimization/99956] New: " rguenth at gcc dot gnu.org
2021-04-07 12:28 ` [Bug tree-optimization/99956] " rguenth at gcc dot gnu.org
2021-04-07 12:29 ` rguenth at gcc dot gnu.org
2021-04-07 12:46 ` rguenth at gcc dot gnu.org [this message]
2021-04-07 12:57 ` rguenth at gcc dot gnu.org
2021-04-26 11:58 ` cvs-commit at gcc dot gnu.org
2021-04-26 11:59 ` rguenth at gcc dot gnu.org

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=bug-99956-4-DWH4aCV5AE@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).