Bug 870095 - Prefer clobbering binary operands with no further uses. r=h4writer
authorSean Stangl <sstangl@mozilla.com>
Wed, 08 May 2013 16:42:50 -0700
changeset 142265 e22a2019d323d39065c2ae9bdc704ca71b53e132
parent 142264 c1ee14175d13d0a1b67fc91d88ea01fa508ece92
child 142266 720d85933172f5bbd6e94272af56c63cc517f5ee
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs870095
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 870095 - Prefer clobbering binary operands with no further uses. r=h4writer
js/src/ion/Lowering.cpp
--- a/js/src/ion/Lowering.cpp
+++ b/js/src/ion/Lowering.cpp
@@ -853,18 +853,20 @@ LIRGenerator::visitCompare(MCompare *com
 }
 
 static void
 ReorderCommutative(MDefinition **lhsp, MDefinition **rhsp)
 {
     MDefinition *lhs = *lhsp;
     MDefinition *rhs = *rhsp;
 
-    // Put the constant in the right-hand side, if there is one.
-    if (lhs->isConstant()) {
+    // Ensure that if there is a constant, then it is in rhs.
+    // In addition, since clobbering binary operations clobber the left
+    // operand, prefer a lhs operand with no further uses.
+    if (lhs->isConstant() || rhs->useCount() == 1) {
         *rhsp = lhs;
         *lhsp = rhs;
     }
 }
 
 bool
 LIRGenerator::lowerBitOp(JSOp op, MInstruction *ins)
 {
@@ -1151,16 +1153,17 @@ LIRGenerator::visitAdd(MAdd *ins)
             return false;
 
         MaybeSetRecoversInput(ins, lir);
         return true;
     }
 
     if (ins->specialization() == MIRType_Double) {
         JS_ASSERT(lhs->type() == MIRType_Double);
+        ReorderCommutative(&lhs, &rhs);
         return lowerForFPU(new LMathD(JSOP_ADD), ins, lhs, rhs);
     }
 
     return lowerBinaryV(JSOP_ADD, ins);
 }
 
 bool
 LIRGenerator::visitSub(MSub *ins)