Commit 0da5b822 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Narrow type of Phis during JSTypedLowering.

Try to narrow types of Phis further during JSTypedLowering, because
lowering based on types might create further opportunities for improving
the types.

R=jarin@chromium.org
BUG=v8:5267

Review-Url: https://codereview.chromium.org/2278903002
Cr-Commit-Position: refs/heads/master@{#38895}
parent a338dad4
......@@ -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:
......
......@@ -80,6 +80,7 @@ class JSTypedLowering final : public AdvancedReducer {
Reduction ReduceLoadField(Node* node);
Reduction ReduceNumberRoundop(Node* node);
Reduction ReduceSelect(Node* node);
Reduction ReducePhi(Node* node);
Reduction ReduceNumberBinop(Node* node);
Reduction ReduceInt32Binop(Node* node);
Reduction ReduceUI32Shift(Node* node, Signedness signedness);
......
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