diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-11-06 11:07:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-06 11:07:08 -0800 |
commit | 033b5e161e677173bda01aad9e6850545b93c97e (patch) | |
tree | 4984374220181ca61044bd7d8849aaec2084c1ec /src/passes/OptimizeInstructions.cpp | |
parent | 5af71eea09abfa9078c62633cea89b121ec4ec08 (diff) | |
parent | 57d0a549d715a25b471c8913c3013fc407eceea6 (diff) | |
download | binaryen-033b5e161e677173bda01aad9e6850545b93c97e.tar.gz binaryen-033b5e161e677173bda01aad9e6850545b93c97e.tar.bz2 binaryen-033b5e161e677173bda01aad9e6850545b93c97e.zip |
Merge pull request #826 from WebAssembly/opts
A few minor optimizations
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 6ba34990f..1970cf08f 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -363,8 +363,12 @@ private: } } } else if (auto* binary = boolean->dynCast<Binary>()) { - // x != 0 is just x if it's used as a bool - if (binary->op == NeInt32) { + if (binary->op == OrInt32) { + // an or flowing into a boolean context can consider each input as boolean + binary->left = optimizeBoolean(binary->left); + binary->right = optimizeBoolean(binary->right); + } else if (binary->op == NeInt32) { + // x != 0 is just x if it's used as a bool if (auto* num = binary->right->dynCast<Const>()) { if (num->value.geti32() == 0) { return binary->left; |