Commit 5dfe23a4 authored by Georgia Kouveli's avatar Georgia Kouveli Committed by Commit Bot

[arm] Match LoadStackPointer with comparison.

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.

Change-Id: Ifd1a5aaf22c9c594e653cf4689ba46587811c4d0
Reviewed-on: https://chromium-review.googlesource.com/1055568Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53161}
parent 8bea9aba
...@@ -73,6 +73,17 @@ class ArmOperandGenerator : public OperandGenerator { ...@@ -73,6 +73,17 @@ class ArmOperandGenerator : 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);
}
}; };
...@@ -1679,17 +1690,17 @@ void VisitWordCompare(InstructionSelector* selector, Node* node, ...@@ -1679,17 +1690,17 @@ void VisitWordCompare(InstructionSelector* selector, Node* node,
if (TryMatchImmediateOrShift(selector, &opcode, m.right().node(), if (TryMatchImmediateOrShift(selector, &opcode, m.right().node(),
&input_count, &inputs[1])) { &input_count, &inputs[1])) {
inputs[0] = g.UseRegister(m.left().node()); inputs[0] = g.UseRegisterOrStackPointer(m.left().node());
input_count++; input_count++;
} else if (TryMatchImmediateOrShift(selector, &opcode, m.left().node(), } else if (TryMatchImmediateOrShift(selector, &opcode, m.left().node(),
&input_count, &inputs[1])) { &input_count, &inputs[1])) {
if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute();
inputs[0] = g.UseRegister(m.right().node()); inputs[0] = g.UseRegisterOrStackPointer(m.right().node());
input_count++; input_count++;
} else { } else {
opcode |= AddressingModeField::encode(kMode_Operand2_R); opcode |= AddressingModeField::encode(kMode_Operand2_R);
inputs[input_count++] = g.UseRegister(m.left().node()); inputs[input_count++] = g.UseRegisterOrStackPointer(m.left().node());
inputs[input_count++] = g.UseRegister(m.right().node()); inputs[input_count++] = g.UseRegisterOrStackPointer(m.right().node());
} }
if (has_result) { if (has_result) {
......
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