]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Force recalculation when relations are registered.
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 14 Nov 2025 20:44:27 +0000 (15:44 -0500)
committerAndrew MacLeod <amacleod@redhat.com>
Sun, 16 Nov 2025 22:20:41 +0000 (17:20 -0500)
Whena relation is registered between 2 ssa-names, update their timestamps.
Any calculations using those names will be stale and forced to recalculate.

* gimple-range-cache.cc (ranger_cache::update_consumers): New.
* gimple-range-cache.h (update_consumers): New prototype.
* gimple-range-fold.cc (fur_depend::fur_depend): Add cache ptr.
(fur_depend::register_relation): call update_consumers.
* gimple-range-fold.h (fur_depend): Add a cache pointer.
* gimple-range.cc (gimple_ranger::fold_range_internal): Add cache ptr.

gcc/gimple-range-cache.cc
gcc/gimple-range-cache.h
gcc/gimple-range-fold.cc
gcc/gimple-range-fold.h
gcc/gimple-range.cc

index ecf03319cd4e8853a3cf119e8301663aee980018..08a953f50128b3eb9be71e9e731b17d13808cb88 100644 (file)
@@ -1108,6 +1108,15 @@ ranger_cache::get_global_range (vrange &r, tree name, bool &current_p)
   return had_global;
 }
 
+// Consumers of NAME that have already calculated values should recalculate.
+// Accomplished by updating the timestamp.
+
+void
+ranger_cache::update_consumers (tree name)
+{
+  m_temporal->set_timestamp (name);
+}
+
 //  Set the global range of NAME to R and give it a timestamp.
 
 void
index 58bf5c57d10e5b2a72849f6db930643690773a10..0a49c12edd0b1a6684f94cfd76ec209ab130a629 100644 (file)
@@ -111,6 +111,7 @@ public:
   bool get_global_range (vrange &r, tree name) const;
   bool get_global_range (vrange &r, tree name, bool &current_p);
   void set_global_range (tree name, const vrange &r, bool changed = true);
+  void update_consumers (tree name);
   range_query &const_query () { return m_globals; }
 
   void propagate_updated_value (tree name, basic_block bb);
index 06c645f3d08174f64a68aceba3f89b10e03596f7..d4481770d76ef16ae3750faa5626d95b17fef43c 100644 (file)
@@ -162,11 +162,10 @@ fur_stmt::query_relation (tree op1, tree op2)
   return m_query->relation ().query (m_stmt, op1, op2);
 }
 
-// Instantiate a stmt based fur_source with a GORI object.
+// Instantiate a stmt based fur_source with a GORI object and a ranger cache.
 
-
-fur_depend::fur_depend (gimple *s, range_query *q)
-  : fur_stmt (s, q)
+fur_depend::fur_depend (gimple *s, range_query *q, ranger_cache *c)
+  : fur_stmt (s, q), m_cache (c)
 {
   m_depend_p = true;
 }
@@ -177,6 +176,13 @@ void
 fur_depend::register_relation (gimple *s, relation_kind k, tree op1, tree op2)
 {
   m_query->relation ().record (s, k, op1, op2);
+  // This new relation could cause different calculations, so mark the operands
+  // with a new timestamp, forcing recalculations.
+  if (m_cache)
+    {
+      m_cache->update_consumers (op1);
+      m_cache->update_consumers (op2);
+    }
 }
 
 // Register a relation on an edge if there is an oracle.
@@ -185,6 +191,13 @@ void
 fur_depend::register_relation (edge e, relation_kind k, tree op1, tree op2)
 {
   m_query->relation ().record (e, k, op1, op2);
+  // This new relation could cause different calculations, so mark the operands
+  // with a new timestamp, forcing recalculations.
+  if (m_cache)
+    {
+      m_cache->update_consumers (op1);
+      m_cache->update_consumers (op2);
+    }
 }
 
 // This version of fur_source will pick a range up from a list of ranges
index 826a10fd9e83fcfe0df3cb72c1ca356c0132f840..760a107821a9c39951975230ca5771103300bb72 100644 (file)
@@ -143,11 +143,13 @@ private:
 class fur_depend : public fur_stmt
 {
 public:
-  fur_depend (gimple *s, range_query *q = NULL);
+  fur_depend (gimple *s, range_query *q = NULL, class ranger_cache *c = NULL);
   virtual void register_relation (gimple *stmt, relation_kind k, tree op1,
                                  tree op2) override;
   virtual void register_relation (edge e, relation_kind k, tree op1,
                                  tree op2) override;
+private:
+  ranger_cache *m_cache;
 };
 
 
index c4093e61d61905af49b1efaf5e539f2880efab6a..f7e0936d39163a56c87aa2542a08fc1814a45783 100644 (file)
@@ -278,7 +278,7 @@ bool
 gimple_ranger::fold_range_internal (vrange &r, gimple *s, tree name)
 {
   fold_using_range f;
-  fur_depend src (s, this);
+  fur_depend src (s, this, &m_cache);
   return f.fold_stmt (r, s, src, name);
 }