public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-5694] Reset SCEV before removing unreachable globals.
@ 2023-02-03 19:43 Andrew Macleod
  0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2023-02-03 19:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:093e2e1b201c0f324e0d8bfe6487aa2d470a13e7

commit r13-5694-g093e2e1b201c0f324e0d8bfe6487aa2d470a13e7
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Wed Feb 1 11:46:18 2023 -0500

    Reset SCEV before removing unreachable globals.
    
    SCEV should be reset in VRP before trying to remove unreachable globals
    to avoid triggering issues with it's cache.
    
            PR tree-optimization/107570
            gcc/
            * tree-vrp.cc (remove_and_update_globals): Reset SCEV.
    
            gcc/testsuite/
            * gcc.dg/pr107570.c: New.

Diff:
---
 gcc/testsuite/gcc.dg/pr107570.c | 25 +++++++++++++++++++++++++
 gcc/tree-vrp.cc                 |  4 ++++
 2 files changed, 29 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/pr107570.c b/gcc/testsuite/gcc.dg/pr107570.c
new file mode 100644
index 00000000000..ba5b535a867
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr107570.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+long int n;
+
+void
+foo (int *p, int x)
+{
+  for (;;)
+    {
+      for (*p = 0; *p < 1; ++*p)
+        {
+          n += *p < 0;
+          if (n < x)
+            {
+              while (x < 1)
+                ++x;
+
+              __builtin_unreachable ();
+            }
+        }
+
+      p = &x;
+    }
+}
diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index 3c431760a16..95547e5419b 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -121,6 +121,10 @@ remove_unreachable::remove_and_update_globals (bool final_p)
   if (m_list.length () == 0)
     return false;
 
+  // Ensure the cache in SCEV has been cleared before processing
+  // globals to be removed.
+  scev_reset ();
+
   bool change = false;
   tree name;
   unsigned i;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-03 19:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 19:43 [gcc r13-5694] Reset SCEV before removing unreachable globals Andrew Macleod

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).