summaryrefslogtreecommitdiff
path: root/src/passes/Flatten.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-11-20 09:25:16 -0800
committerGitHub <noreply@github.com>2018-11-20 09:25:16 -0800
commit7ca9e24aa22bc57a4d37d3018cd02cf39cd9957a (patch)
tree4290dc66afe4c20697186216d9911397bfa2e872 /src/passes/Flatten.cpp
parent801ff52bd0e7696ff105efd2a46932fa5f076708 (diff)
downloadbinaryen-7ca9e24aa22bc57a4d37d3018cd02cf39cd9957a.tar.gz
binaryen-7ca9e24aa22bc57a4d37d3018cd02cf39cd9957a.tar.bz2
binaryen-7ca9e24aa22bc57a4d37d3018cd02cf39cd9957a.zip
Switch optimizations in remove-unused-brs (#1753)
* Switch optimizations in remove-unused-brs: thread switch jumps, and turn a switch with all identical targets into a br * refinalize in interm operations in remove-unused-brs, as we can be confused by it
Diffstat (limited to 'src/passes/Flatten.cpp')
-rw-r--r--src/passes/Flatten.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp
index f4b468098..aa5c1a491 100644
--- a/src/passes/Flatten.cpp
+++ b/src/passes/Flatten.cpp
@@ -53,8 +53,9 @@
#include <wasm.h>
#include <pass.h>
#include <wasm-builder.h>
-#include <ir/utils.h>
+#include <ir/branch-utils.h>
#include <ir/effects.h>
+#include <ir/utils.h>
namespace wasm {
@@ -232,11 +233,7 @@ struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpress
Index temp = builder.addVar(getFunction(), type);
ourPreludes.push_back(builder.makeSetLocal(temp, sw->value));
// we don't know which break target will be hit - assign to them all
- std::set<Name> names;
- for (auto target : sw->targets) {
- names.insert(target);
- }
- names.insert(sw->default_);
+ auto names = BranchUtils::getUniqueTargets(sw);
for (auto name : names) {
ourPreludes.push_back(builder.makeSetLocal(
getTempForBreakTarget(name, type),