diff options
author | Alon Zakai <azakai@google.com> | 2023-08-08 16:04:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 16:04:10 -0700 |
commit | ef17febfd7106ee5330c01c66fbf8d3f6fdc0e03 (patch) | |
tree | 887e86c4d4fc1d8deaa1093d7ea00e2ed67408e5 /src | |
parent | 6537640f95a08aaf5f4829e34adc1f9755892af8 (diff) | |
download | binaryen-ef17febfd7106ee5330c01c66fbf8d3f6fdc0e03.tar.gz binaryen-ef17febfd7106ee5330c01c66fbf8d3f6fdc0e03.tar.bz2 binaryen-ef17febfd7106ee5330c01c66fbf8d3f6fdc0e03.zip |
LocalCSE: Connect adjacent blocks in LinearExecutionWalker (#5867)
Followup to #5860, this does the same for LocalCSE.
As there, this is valid because it's ok if we branch away. This pass adds a local.tee of
a reused value and then gets it later, and it's ok to add a tee even if we branch away
and do not use it.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/LocalCSE.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/passes/LocalCSE.cpp b/src/passes/LocalCSE.cpp index 2b9b26f0e..9e92093e1 100644 --- a/src/passes/LocalCSE.cpp +++ b/src/passes/LocalCSE.cpp @@ -232,6 +232,11 @@ struct Scanner // information, leaving the things we need later. } + // It is ok to look at adjacent blocks together, as if a later part of a block + // is not reached that is fine - changes we make there would not be reached in + // that case. + bool connectAdjacentBlocks = true; + void visitExpression(Expression* curr) { // Compute the hash, using the pre-computed hashes of the children, which // are saved. This allows us to hash everything in linear time. @@ -465,6 +470,9 @@ struct Checker assert(self->activeOriginals.empty()); } + // See the same code above. + bool connectAdjacentBlocks = true; + void visitFunction(Function* curr) { // At the end of the function there can be no active originals. assert(activeOriginals.empty()); @@ -516,6 +524,9 @@ struct Applier // Clear the state between blocks. self->originalLocalMap.clear(); } + + // See the same code above. + bool connectAdjacentBlocks = true; }; } // anonymous namespace |