summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tools/wasm2js.cpp7
-rw-r--r--test/wasm2js/emscripten.2asm.js.opt4
2 files changed, 3 insertions, 8 deletions
diff --git a/src/tools/wasm2js.cpp b/src/tools/wasm2js.cpp
index d64f0b0ab..24e4037e7 100644
--- a/src/tools/wasm2js.cpp
+++ b/src/tools/wasm2js.cpp
@@ -254,13 +254,8 @@ static void optimizeJS(Ref ast, Wasm2JSBuilder::Flags flags) {
return false;
};
+ // Optimize given that the expression is flowing into a boolean context
auto optimizeBoolean = [&](Ref node) {
- if (isConstantBinary(node, XOR, 1)) {
- // x ^ 1 => !x
- node[0]->setString(UNARY_PREFIX);
- node[1]->setString(L_NOT);
- node[3]->setNull();
- }
// TODO: in some cases it may be possible to turn
//
// if (x | 0)
diff --git a/test/wasm2js/emscripten.2asm.js.opt b/test/wasm2js/emscripten.2asm.js.opt
index 35f2958e0..2661d3c1d 100644
--- a/test/wasm2js/emscripten.2asm.js.opt
+++ b/test/wasm2js/emscripten.2asm.js.opt
@@ -155,13 +155,13 @@ function asmFunc(global, env, buffer) {
bools(HEAP32[0] & 1);
bools(HEAPU8[0] & 2);
bools($0 ^ 1);
- if (!$0) {
+ if ($0 ^ 1) {
bools(2)
}
if ($0 ^ 2) {
bools(2)
}
- bools(!!$0);
+ bools(!($0 ^ 1));
abort();
}