]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Update ranger timestamps for inferred ranges.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 14 Jul 2026 18:55:44 +0000 (14:55 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 15 Jul 2026 20:03:45 +0000 (16:03 -0400)
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.

gcc/gimple-range-cache.cc
gcc/gimple-range-infer.cc
gcc/testsuite/gcc.dg/pr126110.c [new file with mode: 0644]

index fc5793ccf6986df39a718a0f281aa73a2203c662..c5a19c866fb098955099af029d566c05b2da2aeb 100644 (file)
@@ -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
index 30b5917e4ede3bf6b4353559f61dc43087bcfcfc..ecd197cf8590f0191ec95c8dda0048979ac177e6 100644 (file)
@@ -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 (file)
index 0000000..278e53d
--- /dev/null
@@ -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" } } */
+