public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-5630] Ranger cache - always use range_from_dom when updating.
Date: Wed,  1 Feb 2023 14:27:19 +0000 (GMT)	[thread overview]
Message-ID: <20230201142719.BEA253858401@sourceware.org> (raw)

https://gcc.gnu.org/g:881bf8de9b07fb501d61ade8f521f1cc9dbe712e

commit r13-5630-g881bf8de9b07fb501d61ade8f521f1cc9dbe712e
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Tue Jan 10 13:40:56 2023 -0500

    Ranger cache - always use range_from_dom when updating.
    
    When updating an existing range, if we dont query the dom tree, we can
    get the global range instead of a proper range on some incoming edges
    which cause the range to not be refined properly.
    
            PR tree-optimization/108356
            gcc/
            * gimple-range-cache.cc (ranger_cache::range_on_edge): Always
            do a search of the DOM tree for a range.
    
            gcc/testsuite/
            * gcc.dg/pr108356.c: New.

Diff:
---
 gcc/gimple-range-cache.cc       |  2 +-
 gcc/testsuite/gcc.dg/pr108356.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index a8202f0e895..20c444bc4f4 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -998,7 +998,7 @@ bool
 ranger_cache::range_on_edge (vrange &r, edge e, tree expr)
 {
   if (gimple_range_ssa_p (expr))
-    return edge_range (r, e, expr, RFD_NONE);
+    return edge_range (r, e, expr, RFD_READ_ONLY);
   return get_tree_range (r, expr, NULL);
 }
 
diff --git a/gcc/testsuite/gcc.dg/pr108356.c b/gcc/testsuite/gcc.dg/pr108356.c
new file mode 100644
index 00000000000..1df6b278e45
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr108356.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+char a;
+static char c = 3;
+char d;
+void foo();
+short(b)(short e, short f) { return e + f; }
+int main() {
+  unsigned g = 0;
+  if (c)
+    ;
+  else
+    foo();
+  for (; g < 2; g = b(g, 2)) {
+    d = g ? 0 : a;
+    if (g)
+      c = 0;
+  }
+}
+
+
+/* { dg-final { scan-tree-dump-not "foo" "optimized" } } */

                 reply	other threads:[~2023-02-01 14:27 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=20230201142719.BEA253858401@sourceware.org \
    --to=amacleod@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).