Chromium Code Reviews| Index: src/ia32/lithium-ia32.cc |
| diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc |
| index 371c16c8e6dab1daab58c074b95f82178f6ee70b..6768f393d229cca21381650da854247c677ac0ba 100644 |
| --- a/src/ia32/lithium-ia32.cc |
| +++ b/src/ia32/lithium-ia32.cc |
| @@ -1392,8 +1392,10 @@ LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
| ASSERT(instr->left()->representation().IsInteger32()); |
| ASSERT(instr->right()->representation().IsInteger32()); |
| - LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| - LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); |
| + LOperand* left = |
| + UseRegisterAtStart(instr->BetterCandidateForRegisterOperand()); |
| + LOperand* right = |
| + UseOrConstantAtStart(instr->WorseCandidateForRegisterOperand()); |
| return DefineSameAsFirst(new(zone()) LBitI(left, right)); |
| } else { |
| ASSERT(instr->representation().IsTagged()); |
| @@ -1560,8 +1562,10 @@ LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
| if (instr->representation().IsInteger32()) { |
| ASSERT(instr->left()->representation().IsInteger32()); |
| ASSERT(instr->right()->representation().IsInteger32()); |
| - LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| - LOperand* right = UseOrConstant(instr->MostConstantOperand()); |
| + LOperand* left = |
| + UseRegisterAtStart(instr->BetterCandidateForRegisterOperand()); |
| + LOperand* right = |
| + UseOrConstant(instr->WorseCandidateForRegisterOperand()); |
| LOperand* temp = NULL; |
| if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) { |
| temp = TempRegister(); |
| @@ -1604,13 +1608,25 @@ LInstruction* LChunkBuilder::DoSub(HSub* instr) { |
| LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { |
| if (instr->representation().IsInteger32()) { |
| + bool use_lea = LAddI::UseLea(instr); |
| ASSERT(instr->left()->representation().IsInteger32()); |
| ASSERT(instr->right()->representation().IsInteger32()); |
| - LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| - LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand()); |
| + LOperand* left = |
| + UseRegisterAtStart(instr->BetterCandidateForRegisterOperand()); |
| + HValue* worse_candidate = instr->WorseCandidateForRegisterOperand(); |
| + LOperand* right = use_lea |
| + ? UseRegisterOrConstantAtStart(worse_candidate) |
| + : UseOrConstantAtStart(worse_candidate); |
| LAddI* add = new(zone()) LAddI(left, right); |
| - LInstruction* result = DefineSameAsFirst(add); |
| - if (instr->CheckFlag(HValue::kCanOverflow)) { |
| + bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
| + // Check to see if it would be advantageous to use |
|
Jakob Kummerow
2013/05/03 09:01:37
nit: use what?
|
| + LInstruction* result = NULL; |
| + if (use_lea) { |
| + result = DefineAsRegister(add); |
| + } else { |
| + result = DefineSameAsFirst(add); |
| + } |
| + if (can_overflow) { |
| result = AssignEnvironment(result); |
| } |
| return result; |
| @@ -1629,8 +1645,8 @@ LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
| if (instr->representation().IsInteger32()) { |
| ASSERT(instr->left()->representation().IsInteger32()); |
| ASSERT(instr->right()->representation().IsInteger32()); |
| - left = UseRegisterAtStart(instr->LeastConstantOperand()); |
| - right = UseOrConstantAtStart(instr->MostConstantOperand()); |
| + left = UseRegisterAtStart(instr->BetterCandidateForRegisterOperand()); |
| + right = UseOrConstantAtStart(instr->WorseCandidateForRegisterOperand()); |
| } else { |
| ASSERT(instr->representation().IsDouble()); |
| ASSERT(instr->left()->representation().IsDouble()); |