Don't swap binary ops when "use asm" is in effect.

Refs #167
This commit is contained in:
Mihai Bazon
2013-06-07 12:51:23 +03:00
parent a4889a0f2e
commit 02a84385a0
2 changed files with 12 additions and 8 deletions

View File

@@ -1765,14 +1765,15 @@ merge(Compressor.prototype, {
var commutativeOperators = makePredicate("== === != !== * & | ^");
OPT(AST_Binary, function(self, compressor){
function reverse(op, force) {
if (force || !(self.left.has_side_effects() || self.right.has_side_effects())) {
if (op) self.operator = op;
var tmp = self.left;
self.left = self.right;
self.right = tmp;
}
};
var reverse = compressor.has_directive("use asm") ? noop
: function(op, force) {
if (force || !(self.left.has_side_effects() || self.right.has_side_effects())) {
if (op) self.operator = op;
var tmp = self.left;
self.left = self.right;
self.right = tmp;
}
};
if (commutativeOperators(self.operator)) {
if (self.right instanceof AST_Constant
&& !(self.left instanceof AST_Constant)) {