diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-26 13:55:29 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-26 13:55:29 -0700 |
commit | 5b348504869e2a60c47173b32f7761fdc96ca132 (patch) | |
tree | f0212acb17dd3ee53f047818644c78b52fea4490 /tools | |
parent | c35860bfad958ec1b7b4f2aa7496705aec5080d9 (diff) |
eliminate X=X which can happen due to elimination
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 9 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 12 | ||||
-rw-r--r-- | tools/js-optimizer.js | 5 |
3 files changed, 25 insertions, 1 deletions
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index 7a8baef2..e1bc83bf 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -810,4 +810,13 @@ function cute($this, $outImage) { } return 0; } +function selfAssign() { + var i1 = 0; + i1 = HEAP32[2] | 0; + HEAP32[2] = i1 + 1; + if (waka) { + return 0; + } + return i1 & 16384 | 0; +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index ad1ed05e..8886d54a 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -1027,5 +1027,15 @@ function cute($this, $outImage) { } return 0; } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2", "binary", "cute"] +function selfAssign() { + var i1 = 0; + i1 = HEAP32[2] | 0; + HEAP32[2] = i1 + 1; + if (waka) { + return (STACKTOP = STACKTOP, 0); + } + STACKTOP = STACKTOP; + return i1 & 16384 | 0; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2", "binary", "cute", "selfAssign"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 129c493f..49bc9d11 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -292,6 +292,8 @@ function removeEmptySubNodes(node) { node[3] = filterEmptyNodes(node[3]); } else if (node[0] === 'block' && node[1]) { node[1] = filterEmptyNodes(node[1]); + } else if (node[0] === 'seq' && isEmptyNode(node[1])) { + return node[2]; } /* var stats = getStatements(node); @@ -3912,6 +3914,9 @@ function eliminate(ast, memSafe) { node[0] = 'toplevel'; node[1] = []; } + } else if (type === 'assign' && node[1] === true && node[2][0] === 'name' && node[3][0] === 'name' && node[2][1] === node[3][1]) { + // elimination led to X = X, which we can just remove + return emptyNode(); } }, function(node, type) { // post |