Commit 80c231e7 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: [arm] Match LoadStackPointer with comparison.

Port 5dfe23a4

Original Commit Message:

    When encountering a LoadStackPointer input to a comparison, generate a register
    LocationOperand that points to the stack pointer. This can avoid unnecessary
    spilling of the stack pointer.

R=georgia.kouveli@arm.com, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Ie3fecf70f78c234fefad86fec74820a61f3d227b
Reviewed-on: https://chromium-review.googlesource.com/1057965Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#53167}
parent e4215e40
...@@ -66,6 +66,17 @@ class PPCOperandGenerator final : public OperandGenerator { ...@@ -66,6 +66,17 @@ class PPCOperandGenerator final : public OperandGenerator {
} }
return false; return false;
} }
// Use the stack pointer if the node is LoadStackPointer, otherwise assign a
// register.
InstructionOperand UseRegisterOrStackPointer(Node* node) {
if (node->opcode() == IrOpcode::kLoadStackPointer) {
return LocationOperand(LocationOperand::EXPLICIT,
LocationOperand::REGISTER,
MachineRepresentation::kWord32, sp.code());
}
return UseRegister(node);
}
}; };
...@@ -1483,15 +1494,15 @@ void VisitWordCompare(InstructionSelector* selector, Node* node, ...@@ -1483,15 +1494,15 @@ void VisitWordCompare(InstructionSelector* selector, Node* node,
// Match immediates on left or right side of comparison. // Match immediates on left or right side of comparison.
if (g.CanBeImmediate(right, immediate_mode)) { if (g.CanBeImmediate(right, immediate_mode)) {
VisitCompare(selector, opcode, g.UseRegister(left), g.UseImmediate(right), VisitCompare(selector, opcode, g.UseRegisterOrStackPointer(left),
cont); g.UseImmediate(right), cont);
} else if (g.CanBeImmediate(left, immediate_mode)) { } else if (g.CanBeImmediate(left, immediate_mode)) {
if (!commutative) cont->Commute(); if (!commutative) cont->Commute();
VisitCompare(selector, opcode, g.UseRegister(right), g.UseImmediate(left), VisitCompare(selector, opcode, g.UseRegisterOrStackPointer(right),
cont); g.UseImmediate(left), cont);
} else { } else {
VisitCompare(selector, opcode, g.UseRegister(left), g.UseRegister(right), VisitCompare(selector, opcode, g.UseRegisterOrStackPointer(left),
cont); g.UseRegisterOrStackPointer(right), cont);
} }
} }
......
...@@ -243,6 +243,17 @@ class S390OperandGenerator final : public OperandGenerator { ...@@ -243,6 +243,17 @@ class S390OperandGenerator final : public OperandGenerator {
bool Is64BitOperand(Node* node) { bool Is64BitOperand(Node* node) {
return MachineRepresentation::kWord64 == GetRepresentation(node); return MachineRepresentation::kWord64 == GetRepresentation(node);
} }
// Use the stack pointer if the node is LoadStackPointer, otherwise assign a
// register.
InstructionOperand UseRegisterOrStackPointer(Node* node) {
if (node->opcode() == IrOpcode::kLoadStackPointer) {
return LocationOperand(LocationOperand::EXPLICIT,
LocationOperand::REGISTER,
MachineRepresentation::kWord32, sp.code());
}
return UseRegister(node);
}
}; };
namespace { namespace {
...@@ -1662,7 +1673,7 @@ void VisitWordCompare(InstructionSelector* selector, Node* node, ...@@ -1662,7 +1673,7 @@ void VisitWordCompare(InstructionSelector* selector, Node* node,
return VisitLoadAndTest(selector, load_and_test, node, left, cont, true); return VisitLoadAndTest(selector, load_and_test, node, left, cont, true);
} }
inputs[input_count++] = g.UseRegister(left); inputs[input_count++] = g.UseRegisterOrStackPointer(left);
if (g.CanBeMemoryOperand(opcode, node, right, effect_level)) { if (g.CanBeMemoryOperand(opcode, node, right, effect_level)) {
// generate memory operand // generate memory operand
AddressingMode addressing_mode = g.GetEffectiveAddressMemoryOperand( AddressingMode addressing_mode = g.GetEffectiveAddressMemoryOperand(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment