Commit 30f0847c authored by George Wort's avatar George Wort Committed by V8 LUCI CQ

[turbofan][arm64] Replace...

[turbofan][arm64] Replace TruncateInt64ToInt32(BitcastTaggedToWordForTagAndSmiBits(Load(x))) with Load(x)

This allows arm64 to produce an extending load from ChangeInt32ToInt64(Load(x)) more frequently.
Reduces embedded code size by 0.66% for arm64.

This change gives 0.3% for Speedometer on an A55 machine.

Change-Id: Ie27a134cea3dfc8a26b87553f27ca01bf9f00f1a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3803227Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: George Wort <george.wort@arm.com>
Cr-Commit-Position: refs/heads/main@{#82258}
parent b7af052c
......@@ -954,6 +954,36 @@ Reduction MachineOperatorReducer::ReduceTruncateInt64ToInt32(Node* node) {
if (m.HasResolvedValue())
return ReplaceInt32(static_cast<int32_t>(m.ResolvedValue()));
if (m.IsChangeInt32ToInt64()) return Replace(m.node()->InputAt(0));
// TruncateInt64ToInt32(BitcastTaggedToWordForTagAndSmiBits(Load(x))) =>
// Load(x)
// where the new Load uses Int32 rather than the tagged representation.
if (m.IsBitcastTaggedToWordForTagAndSmiBits() && m.node()->UseCount() == 1) {
Node* input = m.node()->InputAt(0);
if (input->opcode() == IrOpcode::kLoad ||
input->opcode() == IrOpcode::kLoadImmutable) {
LoadRepresentation load_rep = LoadRepresentationOf(input->op());
if (ElementSizeLog2Of(load_rep.representation()) == 2) {
// Ensure that the value output of the load is only ever used by the
// BitcastTaggedToWordForTagAndSmiBits.
int value_edges = 0;
for (Edge edge : input->use_edges()) {
if (NodeProperties::IsValueEdge(edge)) ++value_edges;
}
if (value_edges == 1) {
// Removing the input is required as node is replaced by the Load, but
// is still used by the the BitcastTaggedToWordForTagAndSmiBits, so
// will prevent future CanCover calls being true.
m.node()->RemoveInput(0);
NodeProperties::ChangeOp(
input,
input->opcode() == IrOpcode::kLoad
? machine()->Load(LoadRepresentation::Int32())
: machine()->LoadImmutable(LoadRepresentation::Int32()));
return Replace(input);
}
}
}
}
return NoChange();
}
......
......@@ -567,6 +567,37 @@ TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32WithConstant) {
}
}
TEST_F(MachineOperatorReducerTest, TruncateInt64ToInt32AfterLoadAndBitcast) {
Node* value = Parameter(0);
Node* inputs[4] = {value, value, graph()->start(), graph()->start()};
LoadRepresentation load_reps[3] = {LoadRepresentation::AnyTagged(),
LoadRepresentation::TaggedPointer(),
LoadRepresentation::TaggedSigned()};
for (LoadRepresentation load_rep : load_reps) {
if (ElementSizeLog2Of(load_rep.representation()) != 2) continue;
{
Node* load = graph()->NewNode(machine()->Load(load_rep), 4, inputs);
Reduction reduction = Reduce(graph()->NewNode(
machine()->TruncateInt64ToInt32(),
graph()->NewNode(machine()->BitcastTaggedToWordForTagAndSmiBits(),
load)));
ASSERT_TRUE(reduction.Changed());
EXPECT_EQ(load, reduction.replacement());
EXPECT_EQ(LoadRepresentationOf(load->op()), LoadRepresentation::Int32());
}
{
Node* load =
graph()->NewNode(machine()->LoadImmutable(load_rep), 2, inputs);
Reduction reduction = Reduce(graph()->NewNode(
machine()->TruncateInt64ToInt32(),
graph()->NewNode(machine()->BitcastTaggedToWordForTagAndSmiBits(),
load)));
ASSERT_TRUE(reduction.Changed());
EXPECT_EQ(load, reduction.replacement());
EXPECT_EQ(LoadRepresentationOf(load->op()), LoadRepresentation::Int32());
}
}
}
// -----------------------------------------------------------------------------
// RoundFloat64ToInt32
......
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