summaryrefslogtreecommitdiff
path: root/src/analysis/lattices/inverted.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-11-02 19:32:32 +0100
committerGitHub <noreply@github.com>2023-11-02 19:32:32 +0100
commit2c3860b8f6e9ba3e0878ecadfdef409da0f471b7 (patch)
treee64e81d7e155a88a7870e292180e0ff60691bbda /src/analysis/lattices/inverted.h
parentf191ace12bb96beed8abbe1fce7049ffd6704f8f (diff)
downloadbinaryen-2c3860b8f6e9ba3e0878ecadfdef409da0f471b7.tar.gz
binaryen-2c3860b8f6e9ba3e0878ecadfdef409da0f471b7.tar.bz2
binaryen-2c3860b8f6e9ba3e0878ecadfdef409da0f471b7.zip
[analysis] Allow joining a single vector element efficiently (#6071)
Previously, modifying a single vector element of a `Shared<Vector>` element required materializing a full vector to do the join. When there is just a single element to update, materializing all the other elements with bottom value is useless work. Add a `Vector<L>::SingletonElement` utility that represents but does not materialize a vector with a single non-bottom element and allow it to be passed to `Vector<L>::join`. Also update `Shared` and `Inverted` so that `SingletonElement` joins still work on vectors wrapped in those other lattices.
Diffstat (limited to 'src/analysis/lattices/inverted.h')
-rw-r--r--src/analysis/lattices/inverted.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/analysis/lattices/inverted.h b/src/analysis/lattices/inverted.h
index b232d89aa..22e326742 100644
--- a/src/analysis/lattices/inverted.h
+++ b/src/analysis/lattices/inverted.h
@@ -37,10 +37,14 @@ template<FullLattice L> struct Inverted {
LatticeComparison compare(const Element& a, const Element& b) const noexcept {
return lattice.compare(b, a);
}
- bool join(Element& joinee, Element joiner) const noexcept {
+
+ template<typename Elem>
+ bool join(Element& joinee, const Elem& joiner) const noexcept {
return lattice.meet(joinee, joiner);
}
- bool meet(Element& meetee, Element meeter) const noexcept {
+
+ template<typename Elem>
+ bool meet(Element& meetee, const Elem& meeter) const noexcept {
return lattice.join(meetee, meeter);
}
};