diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js-optimizer.js | 11 | ||||
-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, 15 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 634d7dda..efbfa8aa 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -486,6 +486,17 @@ function simplifyExpressionsPre(ast) { } } }); + + if (asm) { + // optimize num >> num, in asm we need this here since we do not run optimizeShifts + traverseGenerated(ast, function(node, type) { + if (type == 'binary' && node[1] == '>>' && node[2][0] == 'num' && node[3][0] == 'num') { + node[0] = 'num'; + node[1] = node[2][1] >> node[3][1]; + node.length = 2; + } + }); + } } // The most common mathop is addition, e.g. in getelementptr done repeatedly. We can join all of those, diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index 84c95360..3437163e 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -4,6 +4,8 @@ function a() { f(347); f(351); f(8); + HEAP[1024] = 5; + HEAP[1024] = 5; } function b($this, $__n) { $this = $this | 0; diff --git a/tools/test-js-optimizer-asm-pre.js b/tools/test-js-optimizer-asm-pre.js index 3042ef66..42eb435a 100644 --- a/tools/test-js-optimizer-asm-pre.js +++ b/tools/test-js-optimizer-asm-pre.js @@ -4,6 +4,8 @@ function a() { f(347 | 0); f(347 | 12); f(347 & 12); + HEAP[4096 >> 2] = 5; + HEAP[(4096 & 8191) >> 2] = 5; } function b($this, $__n) { $this = $this | 0; |