diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-04 10:32:09 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-04 10:39:36 -0800 |
commit | 87c84e8898c0a4ff9af8596f1558b469ea672327 (patch) | |
tree | 74e9fbbb1c9f4f70216f2e6038bd12d700356cf5 /tools/js-optimizer.js | |
parent | 6d3d82bb13b8a7377e1bc8e1a65a80a2e013af4a (diff) |
optimize num >> num in js optimizer, necessary for asm now that we do not do shift optimization there
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 11 |
1 files changed, 11 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, |