diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-06-07 11:12:05 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-06-07 11:13:13 -0700 |
commit | c6d56fb9da9eb2ecafadec1a951c98db17092b18 (patch) | |
tree | 824fc1251ced1fc66e3edcdda941905d0ae1f2e3 | |
parent | 6467d20032135ec016301d8bf03b80e92cdb2ad1 (diff) |
optimize out double not
-rw-r--r-- | tools/js-optimizer.js | 30 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-last-output.js | 3 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-last.js | 6 |
3 files changed, 26 insertions, 13 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 7681cf8d..7e1d374f 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -951,19 +951,23 @@ function optimizeShiftsAggressive(ast) { // if (!(x < 5)) // or such. Simplifying these saves space and time. function simplifyNotCompsDirect(node) { - if (node[0] == 'unary-prefix' && node[1] == '!' && node[2][0] == 'binary') { - if (node[2][1] == '<') { - return ['binary', '>=', node[2][2], node[2][3]]; - } else if (node[2][1] == '>') { - return ['binary', '<=', node[2][2], node[2][3]]; - } else if (node[2][1] == '==') { - return ['binary', '!=', node[2][2], node[2][3]]; - } else if (node[2][1] == '!=') { - return ['binary', '==', node[2][2], node[2][3]]; - } else if (node[2][1] == '===') { - return ['binary', '!==', node[2][2], node[2][3]]; - } else if (node[2][1] == '!==') { - return ['binary', '===', node[2][2], node[2][3]]; + if (node[0] == 'unary-prefix' && node[1] == '!') { + if (node[2][0] == 'binary') { + if (node[2][1] == '<') { + return ['binary', '>=', node[2][2], node[2][3]]; + } else if (node[2][1] == '>') { + return ['binary', '<=', node[2][2], node[2][3]]; + } else if (node[2][1] == '==') { + return ['binary', '!=', node[2][2], node[2][3]]; + } else if (node[2][1] == '!=') { + return ['binary', '==', node[2][2], node[2][3]]; + } else if (node[2][1] == '===') { + return ['binary', '!==', node[2][2], node[2][3]]; + } else if (node[2][1] == '!==') { + return ['binary', '===', node[2][2], node[2][3]]; + } + } else if (node[2][0] == 'unary-prefix' && node[2][1] == '!') { + return node[2][2]; } } return node; diff --git a/tools/test-js-optimizer-asm-last-output.js b/tools/test-js-optimizer-asm-last-output.js index 051f950d..1dacd0cd 100644 --- a/tools/test-js-optimizer-asm-last-output.js +++ b/tools/test-js-optimizer-asm-last-output.js @@ -39,5 +39,8 @@ function looop() { do { do_it(); } while (a <= b); + do { + do_it(); + } while (x()); } diff --git a/tools/test-js-optimizer-asm-last.js b/tools/test-js-optimizer-asm-last.js index 9ca32320..e83822f8 100644 --- a/tools/test-js-optimizer-asm-last.js +++ b/tools/test-js-optimizer-asm-last.js @@ -45,6 +45,12 @@ function looop() { break; } } + while (1) { + do_it(); + if (!x()) { + break; + } + } } // EMSCRIPTEN_GENERATED_FUNCTIONS: ["finall", "looop"] |