Index: src/compiler/ppc/instruction-selector-ppc.cc |
diff --git a/src/compiler/ppc/instruction-selector-ppc.cc b/src/compiler/ppc/instruction-selector-ppc.cc |
index a2eb7b8f22c9b8cfde94852c105550b0516db725..ff7199a223f5a780fe2f80314d508629e915849a 100644 |
--- a/src/compiler/ppc/instruction-selector-ppc.cc |
+++ b/src/compiler/ppc/instruction-selector-ppc.cc |
@@ -810,49 +810,70 @@ void InstructionSelector::VisitWord32Sar(Node* node) { |
#if !V8_TARGET_ARCH_PPC64 |
void VisitPairBinop(InstructionSelector* selector, InstructionCode opcode, |
- Node* node) { |
+ InstructionCode opcode2, Node* node) { |
PPCOperandGenerator g(selector); |
- // We use UseUniqueRegister here to avoid register sharing with the output |
- // registers. |
- InstructionOperand inputs[] = { |
- g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)), |
- g.UseRegister(node->InputAt(2)), g.UseUniqueRegister(node->InputAt(3))}; |
+ Node* projection1 = NodeProperties::FindProjection(node, 1); |
+ if (projection1) { |
+ // We use UseUniqueRegister here to avoid register sharing with the output |
+ // registers. |
+ InstructionOperand inputs[] = { |
+ g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)), |
+ g.UseRegister(node->InputAt(2)), g.UseUniqueRegister(node->InputAt(3))}; |
- InstructionOperand outputs[] = { |
- g.DefineAsRegister(node), |
- g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; |
+ InstructionOperand outputs[] = { |
+ g.DefineAsRegister(node), |
+ g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; |
- selector->Emit(opcode, 2, outputs, 4, inputs); |
+ selector->Emit(opcode, 2, outputs, 4, inputs); |
+ } else { |
+ // The high word of the result is not used, so we emit the standard 32 bit |
+ // instruction. |
+ selector->Emit(opcode2, g.DefineSameAsFirst(node), |
+ g.UseRegister(node->InputAt(0)), |
+ g.UseRegister(node->InputAt(2))); |
+ } |
} |
void InstructionSelector::VisitInt32PairAdd(Node* node) { |
- VisitPairBinop(this, kPPC_AddPair, node); |
+ VisitPairBinop(this, kPPC_AddPair, kPPC_Add, node); |
} |
void InstructionSelector::VisitInt32PairSub(Node* node) { |
- VisitPairBinop(this, kPPC_SubPair, node); |
+ VisitPairBinop(this, kPPC_SubPair, kPPC_Sub, node); |
} |
void InstructionSelector::VisitInt32PairMul(Node* node) { |
PPCOperandGenerator g(this); |
- InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), |
- g.UseUniqueRegister(node->InputAt(1)), |
- g.UseUniqueRegister(node->InputAt(2)), |
- g.UseRegister(node->InputAt(3))}; |
+ Node* projection1 = NodeProperties::FindProjection(node, 1); |
+ if (projection1) { |
+ InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), |
+ g.UseUniqueRegister(node->InputAt(1)), |
+ g.UseUniqueRegister(node->InputAt(2)), |
+ g.UseUniqueRegister(node->InputAt(3))}; |
- InstructionOperand outputs[] = { |
- g.DefineAsRegister(node), |
- g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; |
+ InstructionOperand outputs[] = { |
+ g.DefineAsRegister(node), |
+ g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; |
- InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; |
+ InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; |
- Emit(kPPC_MulPair, 2, outputs, 4, inputs, 2, temps); |
+ Emit(kPPC_MulPair, 2, outputs, 4, inputs, 2, temps); |
+ } else { |
+ // The high word of the result is not used, so we emit the standard 32 bit |
+ // instruction. |
+ Emit(kPPC_Mul32, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), |
+ g.UseRegister(node->InputAt(2))); |
+ } |
} |
+namespace { |
+// Shared routine for multiple shift operations. |
void VisitPairShift(InstructionSelector* selector, InstructionCode opcode, |
Node* node) { |
PPCOperandGenerator g(selector); |
+ // We use g.UseUniqueRegister here to guarantee that there is |
+ // no register aliasing of input registers with output registers. |
Int32Matcher m(node->InputAt(2)); |
InstructionOperand shift_operand; |
if (m.HasValue()) { |
@@ -861,16 +882,27 @@ void VisitPairShift(InstructionSelector* selector, InstructionCode opcode, |
shift_operand = g.UseUniqueRegister(m.node()); |
} |
- InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0)), |
- g.UseRegister(node->InputAt(1)), |
+ InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), |
+ g.UseUniqueRegister(node->InputAt(1)), |
shift_operand}; |
- InstructionOperand outputs[] = { |
- g.DefineSameAsFirst(node), |
- g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; |
+ Node* projection1 = NodeProperties::FindProjection(node, 1); |
- selector->Emit(opcode, 2, outputs, 3, inputs); |
+ InstructionOperand outputs[2]; |
+ InstructionOperand temps[1]; |
+ int32_t output_count = 0; |
+ int32_t temp_count = 0; |
+ |
+ outputs[output_count++] = g.DefineAsRegister(node); |
+ if (projection1) { |
+ outputs[output_count++] = g.DefineAsRegister(projection1); |
+ } else { |
+ temps[temp_count++] = g.TempRegister(); |
+ } |
+ |
+ selector->Emit(opcode, output_count, outputs, 3, inputs, temp_count, temps); |
} |
+} // namespace |
void InstructionSelector::VisitWord32PairShl(Node* node) { |
VisitPairShift(this, kPPC_ShiftLeftPair, node); |