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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 2278903002: [turbofan] Narrow type of Phis during JSTypedLowering. (Closed)
Patch Set: Created 4 years, 4 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 | « src/compiler/js-typed-lowering.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index ed8f3b0dae4afa3f5db2af01cef9c10f2d79852d..bfcbd54777b09a6e90e38f73f8ee783e668ab541 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -1926,6 +1926,26 @@ Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) {
return Changed(element);
}
+Reduction JSTypedLowering::ReducePhi(Node* node) {
+ // Try to narrow the type of the Phi {node}, which might be more precise now
+ // after lowering based on types, i.e. a SpeculativeNumberAdd has a more
+ // precise type than the JSAdd that was in the graph when the Typer was run.
+ DCHECK_EQ(IrOpcode::kPhi, node->opcode());
+ int arity = node->op()->ValueInputCount();
+ Type* type = NodeProperties::GetType(node->InputAt(0));
+ for (int i = 1; i < arity; ++i) {
+ type = Type::Union(type, NodeProperties::GetType(node->InputAt(i)),
+ graph()->zone());
+ }
+ Type* const node_type = NodeProperties::GetType(node);
+ if (!node_type->Is(type)) {
+ type = Type::Intersect(node_type, type, graph()->zone());
+ NodeProperties::SetType(node, type);
+ return Changed(node);
+ }
+ return NoChange();
+}
+
Reduction JSTypedLowering::ReduceSelect(Node* node) {
DCHECK_EQ(IrOpcode::kSelect, node->opcode());
Node* const condition = NodeProperties::GetValueInput(node, 0);
@@ -2166,6 +2186,8 @@ Reduction JSTypedLowering::Reduce(Node* node) {
return ReduceJSGeneratorRestoreContinuation(node);
case IrOpcode::kJSGeneratorRestoreRegister:
return ReduceJSGeneratorRestoreRegister(node);
+ case IrOpcode::kPhi:
+ return ReducePhi(node);
case IrOpcode::kSelect:
return ReduceSelect(node);
case IrOpcode::kCheckMaps:
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698