Bug 779361 - Reuse input in LAbsD and LSqrtD. r=pierron
authorSean Stangl <sstangl@mozilla.com>
Tue, 31 Jul 2012 20:48:26 -0700
changeset 102791 f35b90ed0b8d7457c956864973826f25c7d39bc2
parent 102790 a2195dd7853253bffefc677c1c67a6908097b447
child 102792 269c2d9f16429dad0dd83faa4d99d427a74f2886
push id1164
push usersean.stangl@gmail.com
push dateWed, 01 Aug 2012 03:48:41 +0000
reviewerspierron
bugs779361
milestone17.0a1
Bug 779361 - Reuse input in LAbsD and LSqrtD. r=pierron
js/src/ion/LIR-Common.h
js/src/ion/Lowering.cpp
js/src/ion/arm/CodeGenerator-arm.cpp
js/src/ion/shared/CodeGenerator-x86-shared.cpp
--- a/js/src/ion/LIR-Common.h
+++ b/js/src/ion/LIR-Common.h
@@ -1217,34 +1217,34 @@ class LAbsI : public LInstructionHelper<
     const LAllocation *input() {
         return this->getOperand(0);
     }
     const LDefinition *output() {
         return this->getDef(0);
     }
 };
 
-// Absolute value of an integer.
+// Absolute value of a double.
 class LAbsD : public LInstructionHelper<1, 1, 0>
 {
   public:
     LIR_HEADER(AbsD);
     LAbsD(const LAllocation &num) {
         setOperand(0, num);
     }
 
     const LAllocation *input() {
         return this->getOperand(0);
     }
     const LDefinition *output() {
         return this->getDef(0);
     }
 };
 
-// Absolute value of an integer.
+// Square root of a double.
 class LSqrtD : public LInstructionHelper<1, 1, 0>
 {
   public:
     LIR_HEADER(SqrtD);
     LSqrtD(const LAllocation &num) {
         setOperand(0, num);
     }
 
--- a/js/src/ion/Lowering.cpp
+++ b/js/src/ion/Lowering.cpp
@@ -654,30 +654,30 @@ LIRGenerator::visitAbs(MAbs *ins)
     MDefinition *num = ins->num();
 
     if (num->type() == MIRType_Int32) {
         LAbsI *lir = new LAbsI(useRegisterAtStart(num));
         // needed to handle abs(INT32_MIN)
         if (!ins->range()->isFinite() && !assignSnapshot(lir))
             return false;
         return defineReuseInput(lir, ins, 0);
-    } else {
-        JS_ASSERT(num->type() == MIRType_Double);
-        LAbsD *lir = new LAbsD(useRegister(num));
-        return define(lir, ins);
     }
+
+    JS_ASSERT(num->type() == MIRType_Double);
+    LAbsD *lir = new LAbsD(useRegisterAtStart(num));
+    return defineReuseInput(lir, ins, 0);
 }
 
 bool
 LIRGenerator::visitSqrt(MSqrt *ins)
 {
     MDefinition *num = ins->num();
     JS_ASSERT(num->type() == MIRType_Double);
     LSqrtD *lir = new LSqrtD(useRegisterAtStart(num));
-    return define(lir, ins);
+    return defineReuseInput(lir, ins, 0);
 }
 
 bool
 LIRGenerator::visitPow(MPow *ins)
 {
     MDefinition *input = ins->input();
     JS_ASSERT(input->type() == MIRType_Double);
 
--- a/js/src/ion/arm/CodeGenerator-arm.cpp
+++ b/js/src/ion/arm/CodeGenerator-arm.cpp
@@ -273,27 +273,27 @@ CodeGeneratorARM::visitOutOfLineBailout(
     masm.ma_b(deoptLabel_);
     return true;
 }
 
 bool
 CodeGeneratorARM::visitAbsD(LAbsD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
-    FloatRegister output = ToFloatRegister(ins->output());
-    masm.as_vabs(output, input);
+    JS_ASSERT(input == ToFloatRegister(ins->output()));
+    masm.as_vabs(input, input);
     return true;
 }
 
 bool
 CodeGeneratorARM::visitSqrtD(LSqrtD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
-    FloatRegister output = ToFloatRegister(ins->output());
-    masm.as_vsqrt(output, input);
+    JS_ASSERT(input == ToFloatRegister(ins->output()));
+    masm.as_vsqrt(input, input);
     return true;
 }
 
 bool
 CodeGeneratorARM::visitAddI(LAddI *ins)
 {
     const LAllocation *lhs = ins->getOperand(0);
     const LAllocation *rhs = ins->getOperand(1);
--- a/js/src/ion/shared/CodeGenerator-x86-shared.cpp
+++ b/js/src/ion/shared/CodeGenerator-x86-shared.cpp
@@ -400,29 +400,29 @@ CodeGeneratorX86Shared::visitOutOfLineBa
     masm.jmp(deoptLabel_);
     return true;
 }
 
 bool
 CodeGeneratorX86Shared::visitAbsD(LAbsD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
-    FloatRegister output = ToFloatRegister(ins->output());
-    masm.xorpd(output, output);
-    masm.subsd(input, output); // negate the sign bit.
-    masm.andpd(input, output); // s & ~s
+    JS_ASSERT(input == ToFloatRegister(ins->output()));
+    masm.xorpd(ScratchFloatReg, ScratchFloatReg);
+    masm.subsd(input, ScratchFloatReg); // negate the sign bit.
+    masm.andpd(ScratchFloatReg, input); // s & ~s
     return true;
 }
 
 bool
 CodeGeneratorX86Shared::visitSqrtD(LSqrtD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
-    FloatRegister output = ToFloatRegister(ins->output());
-    masm.sqrtsd(input, output);
+    JS_ASSERT(input == ToFloatRegister(ins->output()));
+    masm.sqrtsd(input, input);
     return true;
 }
 
 bool
 CodeGeneratorX86Shared::visitPowHalfD(LPowHalfD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
     Register scratch = ToRegister(ins->temp());