aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-07-06 15:52:34 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-07-06 15:52:34 -0700
commite07907aaa02f4cf30f8b042065ecaad96dcadcf3 (patch)
tree35ab027c5167383174241aada74f4f77c9e8dcaa /tools/js-optimizer.js
parent69f3af28ffdfd766c8652a275a1f9b7f548022a0 (diff)
unused << >> optimization in js optimizer
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 29887e62..d58c8c6c 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -671,6 +671,18 @@ function optimizeShiftsInternal(ast, conservative) {
}
}
}
+ /* XXX - theoretically useful optimization(s), but commented out as not helpful in practice
+ // Transform (x << 2) >> 2 into x & mask or something even simpler
+ if (type == 'binary' && node[1] == '>>' && node[3][0] == 'num' &&
+ node[2][0] == 'binary' && node[2][1] == '<<' && node[2][3][0] == 'num' && node[3][1] == node[2][3][1]) {
+ var subNode = node[2];
+ var shifts = node[3][1];
+ var mask = ((0xffffffff << shifts) >>> shifts) | 0;
+ return ['binary', '&', subNode[2], ['num', mask]];
+ //return ['binary', '|', subNode[2], ['num', 0]];
+ //return subNode[2];
+ }
+ */
});
// Re-combine remaining shifts, to undo the breaking up we did before. may require reordering inside +'s
traverse(fun, function(node, type, stack) {