Commit 4bd6f82c authored by Sam Parker's avatar Sam Parker Committed by V8 LUCI CQ

[arm64][compiler] Instruction select add/sub sxtw

Modify TryAnyExtendMatch to combine Int64Add/Int64Sub(x, ChangeInt32ToInt64(y))
to use an extend register operand, removing the cast.

Change-Id: Id130f8a9614e2c208f9ed8c17b923ee738fcb916
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2857964Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Martyn Capewell <martyn.capewell@arm.com>
Cr-Commit-Position: refs/heads/master@{#74285}
parent ad5f34a1
......@@ -354,6 +354,12 @@ bool TryMatchAnyExtend(Arm64OperandGenerator* g, InstructionSelector* selector,
return true;
}
}
} else if (nm.IsChangeInt32ToInt64()) {
// Use extended register form.
*opcode |= AddressingModeField::encode(kMode_Operand2_R_SXTW);
*left_op = g->UseRegister(left_node);
*right_op = g->UseRegister(right_node->InputAt(0));
return true;
}
return false;
}
......
......@@ -642,6 +642,21 @@ TEST_P(InstructionSelectorAddSubTest, SignedExtendHalfword) {
ASSERT_EQ(1U, s[0]->OutputCount());
}
TEST_P(InstructionSelectorAddSubTest, SignedExtendWord) {
const AddSub dpi = GetParam();
const MachineType type = dpi.mi.machine_type;
if (type != MachineType::Int64()) return;
StreamBuilder m(this, type, type, type);
m.Return((m.*dpi.mi.constructor)(m.Parameter(0),
m.ChangeInt32ToInt64(m.Parameter(1))));
Stream s = m.Build();
ASSERT_EQ(1U, s.size());
EXPECT_EQ(dpi.mi.arch_opcode, s[0]->arch_opcode());
EXPECT_EQ(kMode_Operand2_R_SXTW, s[0]->addressing_mode());
ASSERT_EQ(2U, s[0]->InputCount());
ASSERT_EQ(1U, s[0]->OutputCount());
}
INSTANTIATE_TEST_SUITE_P(InstructionSelectorTest, InstructionSelectorAddSubTest,
::testing::ValuesIn(kAddSubInstructions));
......
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