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

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

Issue 2920193004: [turbofan] Improve representation selection for type guard. (Closed)
Patch Set: Created 3 years, 6 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-726554.js » ('j') | 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 367a1cca7ccdda588297e3f0b353429e12e312b0..09f0b7f2d4d2cd61fd42a1a86a1662bb012a9443 100644
--- a/src/compiler/simplified-lowering.cc
+++ b/src/compiler/simplified-lowering.cc
@@ -730,7 +730,11 @@ class RepresentationSelector {
!GetUpperBound(node->InputAt(1))->Maybe(type);
}
- void ConvertInput(Node* node, int index, UseInfo use) {
+ // Converts input {index} of {node} according to given UseInfo {use},
+ // assuming the type of the input is {input_type}. If {input_type} is null,
+ // it takes the input from the input node {TypeOf(node->InputAt(index))}.
+ void ConvertInput(Node* node, int index, UseInfo use,
+ Type* input_type = nullptr) {
Node* input = node->InputAt(index);
// In the change phase, insert a change before the use if necessary.
if (use.representation() == MachineRepresentation::kNone)
@@ -748,8 +752,11 @@ class RepresentationSelector {
TRACE(" to ");
PrintUseInfo(use);
TRACE("\n");
+ if (input_type == nullptr) {
+ input_type = TypeOf(input);
+ }
Node* n = changer_->GetRepresentationFor(
- input, input_info->representation(), TypeOf(input), node, use);
+ input, input_info->representation(), input_type, node, use);
node->ReplaceInput(index, n);
}
}
@@ -2817,18 +2824,22 @@ class RepresentationSelector {
case IrOpcode::kObjectState:
return VisitObjectState(node);
case IrOpcode::kTypeGuard: {
- // We just get rid of the sigma here. In principle, it should be
- // possible to refine the truncation and representation based on
- // the sigma's type.
+ // We just get rid of the sigma here, choosing the best representation
+ // for the sigma's type.
+ Type* type = TypeOf(node);
MachineRepresentation representation =
- GetOutputInfoForPhi(node, TypeOf(node->InputAt(0)), truncation);
-
- // For now, we just handle specially the impossible case.
- MachineRepresentation output = TypeOf(node)->IsInhabited()
- ? representation
- : MachineRepresentation::kNone;
+ GetOutputInfoForPhi(node, type, truncation);
- VisitUnop(node, UseInfo(representation, truncation), output);
+ // Here we pretend that the input has the sigma's type for the
+ // conversion.
+ UseInfo use(representation, truncation);
+ if (propagate()) {
+ EnqueueInput(node, 0, use);
+ } else if (lower()) {
+ ConvertInput(node, 0, use, type);
+ }
+ ProcessRemainingInputs(node, 1);
+ SetOutput(node, representation);
if (lower()) DeferReplacement(node, node->InputAt(0));
return;
}
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-726554.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698