summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-03-16 14:41:50 -0700
committerGitHub <noreply@github.com>2020-03-16 14:41:50 -0700
commit83d69b30b56fdc9966c84082092fe25830472dd1 (patch)
tree712061cdae10da36bb6158d87f6947471ede4750 /src
parentaadec4526b339af4d2d2b92d3d64f07f935df7a5 (diff)
downloadbinaryen-83d69b30b56fdc9966c84082092fe25830472dd1.tar.gz
binaryen-83d69b30b56fdc9966c84082092fe25830472dd1.tar.bz2
binaryen-83d69b30b56fdc9966c84082092fe25830472dd1.zip
Handle tuples in RemoveUnusedBrs (#2693)
RemoveUnusedBrs produces selects for some patterns, but selects of multivalue types are not valid. This change checks that types are not tuple types before producing selects.
Diffstat (limited to 'src')
-rw-r--r--src/passes/RemoveUnusedBrs.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp
index 2d944d212..5d1b70ad5 100644
--- a/src/passes/RemoveUnusedBrs.cpp
+++ b/src/passes/RemoveUnusedBrs.cpp
@@ -321,6 +321,10 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
// zero (also 3 bytes). The size is unchanged, but the select may
// be further optimizable, and if select does not branch we also
// avoid one branch.
+ // Multivalue selects are not supported
+ if (br->value && br->value->type.isMulti()) {
+ return;
+ }
// If running the br's condition unconditionally is too expensive,
// give up.
auto* zero = LiteralUtils::makeZero(Type::i32, *getModule());
@@ -918,8 +922,8 @@ struct RemoveUnusedBrs : public WalkerPass<PostWalker<RemoveUnusedBrs>> {
// Convert an if into a select, if possible and beneficial to do so.
Select* selectify(If* iff) {
- if (!iff->ifFalse || !iff->ifTrue->type.isConcrete() ||
- !iff->ifFalse->type.isConcrete()) {
+ if (!iff->ifFalse || !iff->ifTrue->type.isSingle() ||
+ !iff->ifFalse->type.isSingle()) {
return nullptr;
}
// This is always helpful for code size, but can be a tradeoff with