Bug 1073478 - IonMonkey: Commute SIMD binary operators r=bbouvier
authorDan Gohman <sunfish@mozilla.com>
Fri, 03 Oct 2014 14:34:39 -0700
changeset 208792 e21f888f27b42050acaba39d5e553798be60441f
parent 208791 527003361b21f2919be95f0d0d3973ce8583a4e3
child 208793 5ac6d1958f310a962b5a2779b208495a80cd7b65
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbbouvier
bugs1073478
milestone35.0a1
Bug 1073478 - IonMonkey: Commute SIMD binary operators r=bbouvier
js/src/jit/Lowering.cpp
--- a/js/src/jit/Lowering.cpp
+++ b/js/src/jit/Lowering.cpp
@@ -3801,16 +3801,19 @@ LIRGenerator::visitSimdSignMask(MSimdSig
     }
 }
 
 bool
 LIRGenerator::visitSimdBinaryComp(MSimdBinaryComp *ins)
 {
     MOZ_ASSERT(ins->type() == MIRType_Int32x4);
 
+    if (ShouldReorderCommutative(ins->lhs(), ins->rhs(), ins))
+        ins->reverse();
+
     if (ins->compareType() == MSimdBinaryComp::CompareInt32x4) {
         LSimdBinaryCompIx4 *add = new(alloc()) LSimdBinaryCompIx4();
         return lowerForCompIx4(add, ins, ins->lhs(), ins->rhs());
     }
 
     if (ins->compareType() == MSimdBinaryComp::CompareFloat32x4) {
         LSimdBinaryCompFx4 *add = new(alloc()) LSimdBinaryCompFx4();
         return lowerForCompFx4(add, ins, ins->lhs(), ins->rhs());
@@ -3820,37 +3823,46 @@ LIRGenerator::visitSimdBinaryComp(MSimdB
     return false;
 }
 
 bool
 LIRGenerator::visitSimdBinaryArith(MSimdBinaryArith *ins)
 {
     MOZ_ASSERT(IsSimdType(ins->type()));
 
+    MDefinition *lhs = ins->lhs();
+    MDefinition *rhs = ins->rhs();
+    if (ins->isCommutative())
+        ReorderCommutative(&lhs, &rhs, ins);
+
     if (ins->type() == MIRType_Int32x4) {
         LSimdBinaryArithIx4 *add = new(alloc()) LSimdBinaryArithIx4();
-        return lowerForFPU(add, ins, ins->lhs(), ins->rhs());
+        return lowerForFPU(add, ins, lhs, rhs);
     }
 
     if (ins->type() == MIRType_Float32x4) {
         LSimdBinaryArithFx4 *add = new(alloc()) LSimdBinaryArithFx4();
-        return lowerForFPU(add, ins, ins->lhs(), ins->rhs());
+        return lowerForFPU(add, ins, lhs, rhs);
     }
 
     MOZ_CRASH("Unknown SIMD kind when adding values");
 }
 
 bool
 LIRGenerator::visitSimdBinaryBitwise(MSimdBinaryBitwise *ins)
 {
     MOZ_ASSERT(IsSimdType(ins->type()));
 
+    MDefinition *lhs = ins->lhs();
+    MDefinition *rhs = ins->rhs();
+    ReorderCommutative(&lhs, &rhs, ins);
+
     if (ins->type() == MIRType_Int32x4 || ins->type() == MIRType_Float32x4) {
         LSimdBinaryBitwiseX4 *lir = new(alloc()) LSimdBinaryBitwiseX4;
-        return lowerForFPU(lir, ins, ins->lhs(), ins->rhs());
+        return lowerForFPU(lir, ins, lhs, rhs);
     }
 
     MOZ_CRASH("Unknown SIMD kind when doing bitwise operations");
     return false;
 }
 
 bool
 LIRGenerator::visitSimdShift(MSimdShift *ins)