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

Unified Diff: src/compiler/load-elimination.cc

Issue 2725593002: [turbofan] Fix handling of typed array loads in load elimination. (Closed)
Patch Set: Created 3 years, 10 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 | test/mjsunit/compiler/regress-694088.js » ('j') | test/mjsunit/compiler/regress-694088.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/load-elimination.cc
diff --git a/src/compiler/load-elimination.cc b/src/compiler/load-elimination.cc
index 10140e1406acbf5f6c27aa36fb041c99f4e8ef84..97b35c0b86445c950d24d2a3b9f1ae8f4ed33bc0 100644
--- a/src/compiler/load-elimination.cc
+++ b/src/compiler/load-elimination.cc
@@ -798,23 +798,48 @@ Reduction LoadElimination::ReduceLoadElement(Node* node) {
Node* const control = NodeProperties::GetControlInput(node);
AbstractState const* state = node_states_.Get(effect);
if (state == nullptr) return NoChange();
- if (Node* replacement = state->LookupElement(object, index)) {
- // Make sure we don't resurrect dead {replacement} nodes.
- if (!replacement->IsDead()) {
- // We might need to guard the {replacement} if the type of the
- // {node} is more precise than the type of the {replacement}.
- Type* const node_type = NodeProperties::GetType(node);
- if (!NodeProperties::GetType(replacement)->Is(node_type)) {
- replacement = graph()->NewNode(common()->TypeGuard(node_type),
- replacement, control);
- NodeProperties::SetType(replacement, node_type);
+
+ // Only handle loads that do not require truncations.
+ ElementAccess const& access = ElementAccessOf(node->op());
+ switch (access.machine_type.representation()) {
+ case MachineRepresentation::kNone:
+ case MachineRepresentation::kSimd1x4:
+ case MachineRepresentation::kSimd1x8:
+ case MachineRepresentation::kSimd1x16:
+ case MachineRepresentation::kBit:
+ UNREACHABLE();
+ break;
+ case MachineRepresentation::kWord8:
+ case MachineRepresentation::kWord16:
+ case MachineRepresentation::kWord32:
+ case MachineRepresentation::kWord64:
+ case MachineRepresentation::kFloat32:
+ // TODO(turbofan): Add support for doing the truncations.
+ break;
+ case MachineRepresentation::kFloat64:
+ case MachineRepresentation::kSimd128:
+ case MachineRepresentation::kTaggedSigned:
+ case MachineRepresentation::kTaggedPointer:
+ case MachineRepresentation::kTagged:
+ if (Node* replacement = state->LookupElement(object, index)) {
+ // Make sure we don't resurrect dead {replacement} nodes.
+ if (!replacement->IsDead()) {
+ // We might need to guard the {replacement} if the type of the
+ // {node} is more precise than the type of the {replacement}.
+ Type* const node_type = NodeProperties::GetType(node);
+ if (!NodeProperties::GetType(replacement)->Is(node_type)) {
+ replacement = graph()->NewNode(common()->TypeGuard(node_type),
+ replacement, control);
+ NodeProperties::SetType(replacement, node_type);
+ }
+ ReplaceWithValue(node, replacement, effect);
+ return Replace(replacement);
+ }
}
- ReplaceWithValue(node, replacement, effect);
- return Replace(replacement);
- }
+ state = state->AddElement(object, index, node, zone());
+ return UpdateState(node, state);
}
- state = state->AddElement(object, index, node, zone());
- return UpdateState(node, state);
+ return NoChange();
}
Reduction LoadElimination::ReduceStoreElement(Node* node) {
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-694088.js » ('j') | test/mjsunit/compiler/regress-694088.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698