diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js-optimizer.js | 3 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre-output.js | 1 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre.js | 1 |
3 files changed, 4 insertions, 1 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 6987511c..95c4121a 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -562,7 +562,8 @@ function simplifyExpressionsPre(ast) { } else if (type === 'binary' && node[1] === '^') { // LLVM represents bitwise not as xor with -1. Translate it back to an actual bitwise not. if (node[3][0] === 'unary-prefix' && node[3][1] === '-' && node[3][2][0] === 'num' && - node[3][2][1] === 1) { + node[3][2][1] === 1 && + !(node[2][0] == 'unary-prefix' && node[2][1] == '~')) { // avoid creating ~~~ which is confusing for asm given the role of ~~ return ['unary-prefix', '~', node[2]]; } } else if (type === 'binary' && node[1] === '>>' && node[3][0] === 'num' && diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index b7afab26..44cc859a 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -66,6 +66,7 @@ function b($this, $__n) { HEAP32[$4] = ~HEAP32[$5]; HEAP32[$4] = ~HEAP32[$5]; HEAP32[$4] = ~HEAP32[$5]; + h(~~g ^ -1); return; } function rett() { diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index b762a60e..2e87224b 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -70,6 +70,7 @@ function b($this, $__n) { HEAP32[$4] = HEAP32[$5]^-1; // Rewrite to ~ and eliminate the |0. HEAP32[$4] = ((HEAP32[$5]|0)^-1)|0; + h((~~g) ^ -1); // do NOT convert this, as it would lead to ~~~ which is confusing in asm, given the role of ~~ return; } function rett() { |