Chromium Code Reviews| Index: src/arm/lithium-arm.cc |
| diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc |
| index 5cd691461f6308949bb47ef62e66fc5f4edcd355..833595c244f6c664da731da7b4d6c704fd8d62e7 100644 |
| --- a/src/arm/lithium-arm.cc |
| +++ b/src/arm/lithium-arm.cc |
| @@ -1328,6 +1328,13 @@ LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
| if (instr->representation().IsInteger32()) { |
| ASSERT(instr->left()->representation().IsInteger32()); |
| ASSERT(instr->right()->representation().IsInteger32()); |
| + |
| + if (instr->left()->IsConstant()) { |
| + // If lhs is constant, do reverse subtraction instead. |
| + ASSERT(!instr->right()->IsConstant()); |
| + return DoRSub(instr); |
| + } |
| + |
| LOperand* left = UseRegisterAtStart(instr->left()); |
| LOperand* right = UseOrConstantAtStart(instr->right()); |
| LSubI* sub = new(zone()) LSubI(left, right); |
| @@ -1343,6 +1350,25 @@ LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
| } |
| } |
| + |
| +LInstruction* LChunkBuilder::DoRSub(HSub* instr) { |
| + ASSERT(instr->representation().IsInteger32()); |
| + ASSERT(instr->left().IsInteger32()); |
|
ulan_google
2012/11/20 08:53:06
This should be ASSERT(instr->left()->representatio
hans
2012/11/20 10:10:19
Done.
|
| + ASSERT(instr->right().IsInteger32()); |
| + |
| + // Note: The lhs of the subtraction becomes the rhs of the |
| + // reverse-subtraction. |
| + LOperand* left = UseRegisterAtStart(instr->right()); |
| + LOperand* right = UseOrConstantAtStart(instr->left()); |
| + LRSubI* rsb = new(zone()) LRSubI(left, right); |
| + LInstruction* result = DefineAsRegister(rsb); |
| + if (instr->CheckFlag(HValue::kCanOverflow)) { |
| + result = AssignEnvironment(result); |
| + } |
| + return result; |
| +} |
| + |
| + |
| LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { |
| LOperand* multiplier_op = UseRegisterAtStart(mul->left()); |
| LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); |