diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-17 20:58:16 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-17 20:58:16 -0700 |
commit | 646e5af8883c87e4c9b8e709c18fb65520199dc6 (patch) | |
tree | f62ff6c12bee1f4765d7ced8becbfb69b64510f5 | |
parent | d45e68797573060a34ea95bd5b94923f80b39bd6 (diff) |
consolidate simplifyExpressions to one pass that happens before closure, where simplifyNotComps is guaranteed to be valid
-rwxr-xr-x | emcc | 6 | ||||
-rwxr-xr-x | tests/runner.py | 8 | ||||
-rw-r--r-- | tools/js-optimizer.js | 10 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-pre-output.js | 8 |
4 files changed, 12 insertions, 20 deletions
@@ -1578,7 +1578,7 @@ try: else: return 'eliminate' - js_optimizer_queue += [get_eliminate(), 'simplifyExpressionsPre'] + js_optimizer_queue += [get_eliminate(), 'simplifyExpressions'] if shared.Settings.RELOOP and not shared.Settings.ASM_JS: js_optimizer_queue += ['optimizeShiftsAggressive', get_eliminate()] # aggressive shifts optimization requires loops, it breaks on switches @@ -1592,10 +1592,6 @@ try: final = shared.Building.closure_compiler(final) if DEBUG: save_intermediate('closure') - if opt_level >= 1: - logging.debug('running post-closure post-opts') - js_optimizer_queue += ['simplifyExpressionsPost'] - if shared.Settings.OUTLINING_LIMIT > 0: js_optimizer_queue += ['outline'] js_optimizer_extra_info['sizeToOutline'] = shared.Settings.OUTLINING_LIMIT diff --git a/tests/runner.py b/tests/runner.py index 17e38c04..020f2bdb 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -11541,11 +11541,11 @@ f.close() def test_js_optimizer(self): for input, expected, passes in [ (path_from_root('tools', 'test-js-optimizer.js'), open(path_from_root('tools', 'test-js-optimizer-output.js')).read(), - ['hoistMultiples', 'loopOptimizer', 'removeAssignsToUndefined', 'simplifyExpressionsPre', 'simplifyExpressionsPost']), + ['hoistMultiples', 'loopOptimizer', 'removeAssignsToUndefined', 'simplifyExpressions']), (path_from_root('tools', 'test-js-optimizer-t2c.js'), open(path_from_root('tools', 'test-js-optimizer-t2c-output.js')).read(), - ['simplifyExpressionsPre', 'optimizeShiftsConservative']), + ['simplifyExpressions', 'optimizeShiftsConservative']), (path_from_root('tools', 'test-js-optimizer-t2.js'), open(path_from_root('tools', 'test-js-optimizer-t2-output.js')).read(), - ['simplifyExpressionsPre', 'optimizeShiftsAggressive']), + ['simplifyExpressions', 'optimizeShiftsAggressive']), # Make sure that optimizeShifts handles functions with shift statements. (path_from_root('tools', 'test-js-optimizer-t3.js'), open(path_from_root('tools', 'test-js-optimizer-t3-output.js')).read(), ['optimizeShiftsAggressive']), @@ -11562,7 +11562,7 @@ f.close() (path_from_root('tools', 'test-js-optimizer-asm-regs-min.js'), open(path_from_root('tools', 'test-js-optimizer-asm-regs-min-output.js')).read(), ['asm', 'registerize']), (path_from_root('tools', 'test-js-optimizer-asm-pre.js'), open(path_from_root('tools', 'test-js-optimizer-asm-pre-output.js')).read(), - ['asm', 'simplifyExpressionsPre']), + ['asm', 'simplifyExpressions']), (path_from_root('tools', 'test-js-optimizer-asm-last.js'), open(path_from_root('tools', 'test-js-optimizer-asm-last-output.js')).read(), ['asm', 'last']), (path_from_root('tools', 'test-js-optimizer-asm-relocate.js'), open(path_from_root('tools', 'test-js-optimizer-asm-relocate-output.js')).read(), diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 3ee1a0b6..dfc4d5dd 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -410,7 +410,7 @@ function removeUnneededLabelSettings(ast) { var USEFUL_BINARY_OPS = set('<<', '>>', '|', '&', '^'); var COMPARE_OPS = set('<', '<=', '>', '>=', '==', '===', '!=', '!=='); -function simplifyExpressionsPre(ast) { +function simplifyExpressions(ast) { // Simplify common expressions used to perform integer conversion operations // in cases where no conversion is needed. function simplifyIntegerConversions(ast) { @@ -793,6 +793,7 @@ function simplifyExpressionsPre(ast) { joinAdditions(func); // simplifyZeroComp(func); TODO: investigate performance if (asm) asmOpts(func); + simplifyNotComps(func); }); } @@ -1158,10 +1159,6 @@ function simplifyNotComps(ast) { simplifyNotCompsPass = false; } -function simplifyExpressionsPost(ast) { - simplifyNotComps(ast); -} - var NO_SIDE_EFFECTS = set('num', 'name'); function hasSideEffects(node) { // this is 99% incomplete! @@ -3478,10 +3475,9 @@ var passes = { unGlobalize: unGlobalize, removeAssignsToUndefined: removeAssignsToUndefined, //removeUnneededLabelSettings: removeUnneededLabelSettings, - simplifyExpressionsPre: simplifyExpressionsPre, + simplifyExpressions: simplifyExpressions, optimizeShiftsConservative: optimizeShiftsConservative, optimizeShiftsAggressive: optimizeShiftsAggressive, - simplifyExpressionsPost: simplifyExpressionsPost, hoistMultiples: hoistMultiples, loopOptimizer: loopOptimizer, registerize: registerize, diff --git a/tools/test-js-optimizer-asm-pre-output.js b/tools/test-js-optimizer-asm-pre-output.js index 8a5803d6..b31327f2 100644 --- a/tools/test-js-optimizer-asm-pre-output.js +++ b/tools/test-js-optimizer-asm-pre-output.js @@ -254,7 +254,7 @@ function _main($argc, $argv) { $j_08_i_i = 0; $i_09_i_i = 1; while (1) { - if (!(($j_08_i_i | 0) < 14)) { + if (($j_08_i_i | 0) >= 14) { label = 49; break; } @@ -361,7 +361,7 @@ function _main($argc, $argv) { $118 = $world + 102952 | 0; HEAP32[$116 + 96 >> 2] = HEAP32[$118 >> 2]; $121 = HEAP32[$118 >> 2] | 0; - if (!(($121 | 0) == 0)) { + if (($121 | 0) != 0) { HEAP32[$121 + 92 >> 2] = $116; } HEAP32[$118 >> 2] = $116; @@ -451,7 +451,7 @@ function _main($argc, $argv) { $y_sroa_0_0_insert_insert$1 = +$y_sroa_1_4_load293550; HEAPF32[$185 >> 2] = $y_sroa_0_0_load283451; HEAPF32[$185 + 4 >> 2] = $y_sroa_0_0_insert_insert$1; - if (!((HEAP32[$98 >> 2] & 2 | 0) == 0)) { + if ((HEAP32[$98 >> 2] & 2 | 0) != 0) { label = 65; break L82; } @@ -466,7 +466,7 @@ function _main($argc, $argv) { HEAP32[$209 + 92 >> 2] = 0; HEAP32[$209 + 96 >> 2] = HEAP32[$118 >> 2]; $213 = HEAP32[$118 >> 2] | 0; - if (!(($213 | 0) == 0)) { + if (($213 | 0) != 0) { HEAP32[$213 + 92 >> 2] = $209; } HEAP32[$118 >> 2] = $209; |