[gcc r17-2427] Update ranger timestamps for inferred ranges.

Andrew Macleod via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:27c5036a82a64012eada494cb19d1ae646b2bcbf

commit r17-2427-g27c5036a82a64012eada494cb19d1ae646b2bcbf
Author: Andrew MacLeod <[email protected]>
Date:   Tue Jul 14 14:55:44 2026 -0400

    Update ranger timestamps for inferred ranges.
    
    If an inferred range is added for a name, mark the name as an updated
    range to allow the dependency processing to pick up the change.
    
            PR tree-optimization/126110
            gcc/
            * gimple-range-cache.cc (ranger_cache::mark_stale): Default defs
            get a new timestamp to make them stale.
            * gimple-range-infer.cc (infer_range_manager::add_range): When
            an inferred range is added, mark the name as updated.
    
            gcc/testsuite/
            * gcc.dg/pr126110.c: New.

Diff:
---
 gcc/gimple-range-cache.cc       | 15 +++++++++++----
 gcc/gimple-range-infer.cc       |  2 ++
 gcc/testsuite/gcc.dg/pr126110.c | 38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index fc5793ccf698..c5a19c866fb0 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1116,10 +1116,17 @@ ranger_cache::get_global_range (vrange &r, tree name) const
 void
 ranger_cache::mark_stale (tree name)
 {
-  // Only mark it as stale if it has been processed. If it has no range
-  // it will be calculated at the next request anyway.
-  if (m_globals.has_range (name))
-    bitmap_set_bit (m_stale, SSA_NAME_VERSION (name));
+  if (SSA_NAME_IS_DEFAULT_DEF (name))
+    {
+      // Default defs have no DEF to recalculate, just create a new timestamp.
+      m_temporal->set_timestamp_stored (name);
+    }
+  else if (m_globals.has_range (name))
+    {
+      // Otherwise Only mark it as stale if it has been processed. If it has no
+      // range it will be calculated at the next request anyway.
+      bitmap_set_bit (m_stale, SSA_NAME_VERSION (name));
+    }
 }
 
 // Get the global range for NAME, and return in R.  Return false if the
diff --git a/gcc/gimple-range-infer.cc b/gcc/gimple-range-infer.cc
index 30b5917e4ede..ecd197cf8590 100644
--- a/gcc/gimple-range-infer.cc
+++ b/gcc/gimple-range-infer.cc
@@ -457,6 +457,8 @@ infer_range_manager::add_range (tree name, gimple *s, const vrange &r)
      fprintf (dump_file, "\n");
    }
 
+  get_range_query (cfun)->update_range_info (name);
+
   // If NAME already has a range, intersect them and done.
   exit_range *ptr = m_on_exit[bb->index].find_ptr (name);
   if (ptr)
diff --git a/gcc/testsuite/gcc.dg/pr126110.c b/gcc/testsuite/gcc.dg/pr126110.c
new file mode 100644
index 000000000000..278e53d02353
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr126110.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+struct rtx {
+  int code;
+};
+
+static inline void *zero ()
+{
+  return 0;
+}
+static inline int three ()
+{
+  return 3;
+}
+
+int
+can_combine_p (struct rtx *insn, struct rtx *elt)
+{
+  struct rtx *set;
+
+  set = zero ();
+  if (insn->code == three ())
+    set = insn;
+  else
+    {
+      set = elt;
+      if (set == zero ())
+        return 0;
+    }
+
+  return (set == zero ());
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "Global Exported: set_.*1," "evrp" } } */
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.