Commit 71becab8 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Lower Smi field loads to Word32 field loads.

If a Smi field load is truncated to Word32, we can just load the upper
32 bits on 64-bit architectures (with 32-bit Smis), which avoids the
nasty shift right that we'd have to perform otherwise to untag it.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2140553002
Cr-Commit-Position: refs/heads/master@{#37630}
parent 4f976328
...@@ -1871,9 +1871,31 @@ class RepresentationSelector { ...@@ -1871,9 +1871,31 @@ class RepresentationSelector {
} }
case IrOpcode::kLoadField: { case IrOpcode::kLoadField: {
FieldAccess access = FieldAccessOf(node->op()); FieldAccess access = FieldAccessOf(node->op());
ProcessInput(node, 0, UseInfoForBasePointer(access)); MachineRepresentation representation =
ProcessRemainingInputs(node, 1); access.machine_type.representation();
SetOutput(node, access.machine_type.representation()); // If we are loading from a Smi field and truncate the result to Word32,
// we can instead just load the high word on 64-bit architectures, which
// is exactly the Word32 we are looking for, and therefore avoid a nasty
// right shift afterwards.
// TODO(bmeurer): Introduce an appropriate tagged-signed machine rep.
if (truncation.TruncatesToWord32() &&
representation == MachineRepresentation::kTagged &&
access.type->Is(Type::TaggedSigned()) && SmiValuesAre32Bits()) {
VisitUnop(node, UseInfoForBasePointer(access),
MachineRepresentation::kWord32);
if (lower()) {
// Morph this Smi load field into an int32 load field.
access.machine_type = MachineType::Int32();
access.type = type_cache_.kInt32;
#if V8_TARGET_LITTLE_ENDIAN
access.offset += kPointerSize / 2;
#endif
NodeProperties::ChangeOp(node,
jsgraph_->simplified()->LoadField(access));
}
} else {
VisitUnop(node, UseInfoForBasePointer(access), representation);
}
return; return;
} }
case IrOpcode::kStoreField: { case IrOpcode::kStoreField: {
......
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