]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Update current query global when system global changes.
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 14 Nov 2025 20:39:18 +0000 (15:39 -0500)
committerAndrew MacLeod <amacleod@redhat.com>
Sun, 16 Nov 2025 22:20:34 +0000 (17:20 -0500)
This ensures a the current range_query's internal tracking of a global value
matches anything another entity sets.

* gimple-range.cc (gimple_ranger::update_range_info): New.
* gimple-range.h (update_range_info): New prototype.
* tree-ssanames.cc (set_range_info): Update the range info for
the current range query.
* value-query.h (update_range_info): New prototype.
* value-query.cc (update_range_info): New default stub.

gcc/gimple-range.cc
gcc/gimple-range.h
gcc/tree-ssanames.cc
gcc/value-query.cc
gcc/value-query.h

index ced574d72f3ca10a44dd011e6086502117082adc..c4093e61d61905af49b1efaf5e539f2880efab6a 100644 (file)
@@ -554,6 +554,18 @@ gimple_ranger::register_transitive_inferred_ranges (basic_block bb)
     }
 }
 
+// This is called to update ranger's concept of a global value for NAME
+// with range R by an outside entity.
+
+void
+gimple_ranger::update_range_info (tree name, const vrange &r)
+{
+  value_range current (TREE_TYPE (name));
+  m_cache.get_global_range (current, name);
+  if (current.intersect (r))
+    m_cache.set_global_range (name, current, true);
+}
+
 // This routine will export whatever global ranges are known to GCC
 // SSA_RANGE_NAME_INFO and SSA_NAME_PTR_INFO fields.
 
index bae75a69ad487182a2008eec77898885cc65b55f..5017a96fd483b44853201a667a8f8a130d4f06f0 100644 (file)
@@ -54,6 +54,7 @@ public:
   virtual bool range_on_edge (vrange &r, edge e, tree name) override;
   virtual bool range_on_entry (vrange &r, basic_block bb, tree name) override;
   virtual bool range_on_exit (vrange &r, basic_block bb, tree name) override;
+  virtual void update_range_info (tree, const vrange &) override;
   void export_global_ranges ();
   virtual void dump (FILE *f) override;
   void debug ();
index 3d915738c987b4e9bf194ec76af37a844887472e..e3788f00f7f233535dc6ec04c1cb2d9ac6e4083d 100644 (file)
@@ -457,6 +457,8 @@ set_range_info (tree name, const vrange &r)
       tmp.dump (dump_file);
       fputc ('\n', dump_file);
     }
+  // Update the active query, if needed.
+  get_range_query (cfun)->update_range_info (name, r);
   return true;
 }
 
index 194a3ffa41c876780dcaf260a888c7424fcbe811..6060abb3d95693b040774398fc17e8efa9037b60 100644 (file)
@@ -66,6 +66,12 @@ range_query::range_of_stmt (vrange &r, gimple *stmt, tree name)
   return false;
 }
 
+// Default for updating range info is to do nothing.
+void
+range_query::update_range_info (tree, const vrange &)
+{
+}
+
 // If the range of expr EXPR at STMT is a single value, return it.
 // Otherwise return NULL_TREE.
 
index eb5b867fc8494e65b3fec68f2c9a2e42177c3fa3..db1bb36e38fa80fd44e55ee1da545c545362be84 100644 (file)
@@ -75,6 +75,8 @@ public:
   virtual bool range_on_entry (vrange &r, basic_block bb, tree expr);
   virtual bool range_on_exit (vrange &r, basic_block bb, tree expr);
 
+  virtual void update_range_info (tree name, const vrange &r);
+
   inline class relation_oracle &relation () const  { return *m_relation; }
   void create_relation_oracle (bool do_trans_p = true);
   void destroy_relation_oracle ();
@@ -105,7 +107,6 @@ protected:
   // This is an internal interface
   void share_query (range_query &q);
   bool m_shared_copy_p;
-
 };
 
 // Global ranges for SSA names using SSA_NAME_RANGE_INFO.