[gcc r15-1346] Add merge facility to ssa_lazy_cache.

Andrew Macleod amacleod@gcc.gnu.org
Fri Jun 14 19:20:00 GMT 2024


https://gcc.gnu.org/g:d40034c489c3d4ae149759ba051ef1d661a6c243

commit r15-1346-gd40034c489c3d4ae149759ba051ef1d661a6c243
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Thu Jun 13 15:35:55 2024 -0400

    Add merge facility to ssa_lazy_cache.
    
    The ssa_lazy_cache has a routine to merge a range for an ssa-name with
    an existing range in the cache.  This adds a method which will merge all
    elements of another ssa_lazy_cache.
    
            * gimple-range-cache.cc (ssa_lazy_cache::merge): New.
            * gimple-range-cache.h (ssa_lazy_cache::merge): New prototype.

Diff:
---
 gcc/gimple-range-cache.cc | 18 ++++++++++++++++++
 gcc/gimple-range-cache.h  |  1 +
 2 files changed, 19 insertions(+)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index a511a2c3a4c2..efaae2ed9281 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -729,6 +729,24 @@ ssa_lazy_cache::merge_range (tree name, const vrange &r)
   return true;
 }
 
+// Merge all elements of CACHE with this cache.
+// Any names in CACHE that are not in this one are added.
+// Any names in both are merged via merge_range..
+
+void
+ssa_lazy_cache::merge (const ssa_lazy_cache &cache)
+{
+  unsigned x;
+  bitmap_iterator bi;
+  EXECUTE_IF_SET_IN_BITMAP (cache.active_p, 0, x, bi)
+    {
+      tree name = ssa_name (x);
+      Value_Range r(TREE_TYPE (name));
+      cache.get_range (r, name);
+      merge_range (ssa_name (x), r);
+    }
+}
+
 // Return TRUE if NAME has a range, and return it in R.
 
 bool
diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h
index c7499f928a94..63410d5437e6 100644
--- a/gcc/gimple-range-cache.h
+++ b/gcc/gimple-range-cache.h
@@ -87,6 +87,7 @@ public:
   virtual bool get_range (vrange &r, tree name) const;
   virtual void clear_range (tree name);
   virtual void clear ();
+  void merge (const ssa_lazy_cache &);
 protected:
   bitmap active_p;
 };


More information about the Gcc-cvs mailing list