diff options
-rw-r--r-- | tools/js-optimizer.js | 6 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre-output.js | 3 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre.js | 3 |
3 files changed, 10 insertions, 2 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 6987511c..71a59921 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' && @@ -636,7 +637,8 @@ function simplifyExpressionsPre(ast) { if (node[0] === 'seq' && node[1][0] === 'assign' && node[1][2][0] === 'sub' && node[1][2][1][0] === 'name' && (node[1][2][1][1] === 'HEAP32' || node[1][2][1][1] === 'HEAPF32') && node[1][2][2][0] === 'binary' && node[1][2][2][2][0] === 'name' && node[1][2][2][2][1] === 'tempDoublePtr' && - node[1][3][0] === 'sub' && node[1][3][1][0] === 'name' && (node[1][3][1][1] === 'HEAP32' || node[1][3][1][1] === 'HEAPF32')) { + node[1][3][0] === 'sub' && node[1][3][1][0] === 'name' && (node[1][3][1][1] === 'HEAP32' || node[1][3][1][1] === 'HEAPF32') && + node[2][0] !== 'seq') { // avoid (x, y, z) which can be used for tempDoublePtr on doubles for alignment fixes if (node[1][2][1][1] === 'HEAP32') { node[1][3][1][1] = 'HEAPF32'; return ['unary-prefix', '+', node[1][3]]; diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index b7afab26..8a5803d6 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() { @@ -156,6 +157,8 @@ function tempDoublePtr($45, $14, $28, $42) { unelim2 = 127 + $14 | 0; func(); HEAP32[4] = unelim2; + barrier(); + $f163 = (HEAP32[tempDoublePtr >> 2] = HEAP32[$f165 >> 2], HEAP32[tempDoublePtr + 4 >> 2] = HEAP32[$f165 + 4 >> 2], +HEAPF64[tempDoublePtr >> 3]); } function boxx($this, $aabb, $xf, $childIndex) { $this = $this | 0; diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index b762a60e..5c004342 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() { @@ -166,6 +167,8 @@ function tempDoublePtr($45, $14, $28, $42) { unelim2 = (HEAP32[tempDoublePtr >> 2] = 127 + $14, +HEAPF32[tempDoublePtr >> 2]); func(); HEAPF32[4] = unelim2; + barrier(); + $f163 = (HEAP32[tempDoublePtr >> 2] = HEAP32[$f165 >> 2], HEAP32[tempDoublePtr + 4 >> 2] = HEAP32[$f165 + 4 >> 2], +HEAPF64[tempDoublePtr >> 3]); } function boxx($this, $aabb, $xf, $childIndex) { $this = $this | 0; |