Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Unified Diff: src/compiler/simplified-lowering.cc

Issue 2140553002: [turbofan] Lower Smi field loads to Word32 field loads. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@TurboFan_Comparison_Signedness
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-lowering.cc
diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc
index 39d473e7a9687b68dcec17eac8a67fdf34284d07..57f3fd5b436ccc60c4633089cf101211ac4b073b 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -1871,9 +1871,31 @@ class RepresentationSelector {
}
case IrOpcode::kLoadField: {
FieldAccess access = FieldAccessOf(node->op());
- ProcessInput(node, 0, UseInfoForBasePointer(access));
- ProcessRemainingInputs(node, 1);
- SetOutput(node, access.machine_type.representation());
+ MachineRepresentation representation =
+ 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;
}
case IrOpcode::kStoreField: {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698