diff options
author | Thomas Lively <tlively@google.com> | 2023-11-02 19:32:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-02 19:32:32 +0100 |
commit | 2c3860b8f6e9ba3e0878ecadfdef409da0f471b7 (patch) | |
tree | e64e81d7e155a88a7870e292180e0ff60691bbda /src/analysis/lattices/shared.h | |
parent | f191ace12bb96beed8abbe1fce7049ffd6704f8f (diff) | |
download | binaryen-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/shared.h')
-rw-r--r-- | src/analysis/lattices/shared.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/analysis/lattices/shared.h b/src/analysis/lattices/shared.h index 489ed0003..e75b895ea 100644 --- a/src/analysis/lattices/shared.h +++ b/src/analysis/lattices/shared.h @@ -106,7 +106,8 @@ template<Lattice L> struct Shared { return false; } - bool join(Element& joinee, const typename L::Element& joiner) const noexcept { + template<typename Elem> + bool join(Element& joinee, const Elem& joiner) const noexcept { if (lattice.join(val, joiner)) { // We have moved to the next value in our ascending chain. Assign it a new // sequence number and update joinee with that sequence number. |