diff mbox series

[COMMITTED] Add merge facility to ssa_lazy_cache.

Message ID 88815a5d-7070-404c-af7c-2d646a82943f@redhat.com
State New
Headers show
Series [COMMITTED] Add merge facility to ssa_lazy_cache. | expand

Commit Message

Andrew MacLeod June 14, 2024, 7:20 p.m. UTC
The ssa_lazy_cache object 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

the ssa_lazy_cache is a reasonably efficient object for storing ranges 
associated a few ssa-names, and it is used in a few places by ranger.

Bootstraps on   x86_64-pc-linux-gnu with no regressions.  There 
shouldn't be, there are no callers yet :-)   Pushed.

Andrew
diff mbox series

Patch

From e2679227829ffe2ff4fb974994aacd639219f855 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Thu, 13 Jun 2024 15:35:55 -0400
Subject: [PATCH 2/7] 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.
---
 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 a511a2c3a4c..efaae2ed928 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 c7499f928a9..63410d5437e 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;
 };
-- 
2.45.0