diff options
author | Alon Zakai <azakai@google.com> | 2022-05-17 12:40:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 19:40:21 +0000 |
commit | 06d5168d02287e51043d581644fcd25c9853a1f7 (patch) | |
tree | 28d4e591447ad147474c6e12f03ace5a72766e93 | |
parent | e74f9e1681d37f5d13dc1025799611ca6d65bbfd (diff) | |
download | binaryen-06d5168d02287e51043d581644fcd25c9853a1f7.tar.gz binaryen-06d5168d02287e51043d581644fcd25c9853a1f7.tar.bz2 binaryen-06d5168d02287e51043d581644fcd25c9853a1f7.zip |
wasm-reduce: Fix order in shrinkByReduction call (#4673)
The old code would short-circuit and not do anything after we managed
any reduction in the loop here. That would end up doing entire iterations of
the whole pipeline before removing another element segment, which could
be slow.
-rw-r--r-- | src/tools/wasm-reduce.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tools/wasm-reduce.cpp b/src/tools/wasm-reduce.cpp index c6f9be0de..b9f8c6dbe 100644 --- a/src/tools/wasm-reduce.cpp +++ b/src/tools/wasm-reduce.cpp @@ -831,7 +831,10 @@ struct Reducer // First, shrink segment elements. bool shrank = false; for (auto& segment : module->elementSegments) { - shrank = shrank || shrinkByReduction(segment.get(), 1); + // Try to shrink all the segments (code in shrinkByReduction will decide + // which to actually try to shrink, based on the current factor), and note + // if we shrank anything at all (which we'll use later down). + shrank = shrinkByReduction(segment.get(), 1) || shrank; } // Second, try to replace elements with a "zero". |