diff options
author | Alon Zakai <azakai@google.com> | 2022-07-29 12:12:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-29 12:12:41 -0700 |
commit | 5a7efea5a6bdaf97ebaa5450811689b348cf28ea (patch) | |
tree | b2c6ed7d2fd12cdf134c1e09e95d5f44d612ef6e /src | |
parent | eb157d230c68cdc91c9da8841a53a80246f345d7 (diff) | |
download | binaryen-5a7efea5a6bdaf97ebaa5450811689b348cf28ea.tar.gz binaryen-5a7efea5a6bdaf97ebaa5450811689b348cf28ea.tar.bz2 binaryen-5a7efea5a6bdaf97ebaa5450811689b348cf28ea.zip |
[NFC] wasm-reduce: Avoid wasted work on drops (#4850)
It was wasted work to see a drop and then check if we can replace it with
a drop of its child, which is identical to the original state. This didn't cause
any harm (we'd not reduce code size, and stop eventually) but it did slow us
down.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/wasm-reduce.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index 52a4be2d4..6febcf6b9 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -590,6 +590,13 @@ struct Reducer tryToReplaceCurrent(loop->body); } return; // nothing more to do + } else if (curr->is<Drop>()) { + if (curr->type == Type::none) { + // We can't improve this: the child has a different type than us. Return + // here to avoid reaching the code below that tries to add a drop on + // children (which would recreate the current state). + return; + } } // Finally, try to replace with a child. for (auto* child : ChildIterator(curr)) { |