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(+)
@@ -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
@@ -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