diff options
-rw-r--r-- | tools/js-optimizer.js | 16 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre-output.js | 2 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre.js | 2 |
3 files changed, 20 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 9b559ee2..7aff3a47 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -543,6 +543,22 @@ function simplifyExpressionsPre(ast) { node[3] = value[1][3]; } } + } else if (type == 'seq') { + // (HEAP32[tempDoublePtr >> 2] = HEAP32[$37 >> 2], +HEAPF32[tempDoublePtr >> 2]) + // ==> + // +HEAPF32[$37 >> 2] + 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')) { + if (node[1][2][1][1] == 'HEAP32') { + node[1][3][1][1] = 'HEAPF32'; + return ['unary-prefix', '+', node[1][3]]; + } else { + node[1][3][1][1] = 'HEAP32'; + return ['binary', '|', node[1][3], ['num', 0]]; + } + } } }); diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index 57a7a4f8..2f1fca1d 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -114,5 +114,7 @@ function tempDoublePtr($45, $14, $28, $42) { $42 = $42 | 0; HEAPF32[$45 >> 2] = ($14 < $28 ? $14 : $28) - $42; HEAP32[$world + 102916 >> 2] = _malloc(192) | 0; + f(+HEAPF32[$45 >> 2]); + g(HEAP32[$14 >> 2] | 0); } diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index 27eff714..16a2566a 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -116,5 +116,7 @@ function tempDoublePtr($45, $14, $28, $42) { $42 = $42 | 0; HEAP32[$45 >> 2] = 0 | (HEAPF32[tempDoublePtr >> 2] = ($14 < $28 ? $14 : $28) - $42, HEAP32[tempDoublePtr >> 2] | 0); HEAP32[$world + 102916 >> 2] = _malloc(192) | 0; + f((HEAP32[tempDoublePtr >> 2] = HEAP32[$45 >> 2], +HEAPF32[tempDoublePtr >> 2])); + g((HEAPF32[tempDoublePtr >> 2] = HEAPF32[$14 >> 2], HEAP32[tempDoublePtr >> 2] | 0)); } // EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "rett", "ret2t", "retf", "i32_8", "tempDoublePtr"] |