Revert of [turbofan] Correctify TruncateFloat64ToInt32 reduction in MachineOperatorReducer. (patchset #1 id:1 of https://codereview.chromium.org/801263002/)
Reason for revert:
Can cause reduce cycles, needs more investigation
Original issue's description:
> [turbofan] Correctify TruncateFloat64ToInt32 reduction in MachineOperatorReducer.
>
> TEST=unittests
> R=svenpanne@chromium.org
>
> Committed: 6e7ceee4d0
TBR=svenpanne@chromium.org
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/794473003
Cr-Commit-Position: refs/heads/master@{#25859}
This commit is contained in:
parent
a75fc3a95b
commit
5a8be47d21
@ -608,52 +608,31 @@ Reduction MachineOperatorReducer::ReduceUint32Mod(Node* node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32Input(
|
Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) {
|
||||||
Node* input) {
|
Float64Matcher m(node->InputAt(0));
|
||||||
Float64Matcher m(input);
|
|
||||||
if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
|
if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
|
||||||
if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
|
if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
|
||||||
return NoChange();
|
if (m.IsPhi()) {
|
||||||
}
|
Node* const phi = m.node();
|
||||||
|
DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(phi)));
|
||||||
|
if (phi->OwnedBy(node)) {
|
||||||
Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) {
|
// TruncateFloat64ToInt32(Phi[Float64](x1,...,xn))
|
||||||
// Try to reduce the input first.
|
// => Phi[Int32](TruncateFloat64ToInt32(x1),
|
||||||
Node* const input = node->InputAt(0);
|
// ...,
|
||||||
Reduction reduction = ReduceTruncateFloat64ToInt32Input(input);
|
// TruncateFloat64ToInt32(xn))
|
||||||
if (reduction.Changed()) return reduction;
|
const int value_input_count = phi->InputCount() - 1;
|
||||||
if (input->opcode() == IrOpcode::kPhi) {
|
for (int i = 0; i < value_input_count; ++i) {
|
||||||
DCHECK_EQ(kRepFloat64, RepresentationOf(OpParameter<MachineType>(input)));
|
Node* input = graph()->NewNode(machine()->TruncateFloat64ToInt32(),
|
||||||
// TruncateFloat64ToInt32(Phi[Float64](x1,...,xn))
|
phi->InputAt(i));
|
||||||
// => Phi[Int32](TruncateFloat64ToInt32(x1),
|
// TODO(bmeurer): Reschedule input for reduction once we have Revisit()
|
||||||
// ...,
|
// instead of recursing into ReduceTruncateFloat64ToInt32() here.
|
||||||
// TruncateFloat64ToInt32(xn))
|
Reduction reduction = ReduceTruncateFloat64ToInt32(input);
|
||||||
int const input_count = input->InputCount() - 1;
|
if (reduction.Changed()) input = reduction.replacement();
|
||||||
Node* const control = input->InputAt(input_count);
|
phi->ReplaceInput(i, input);
|
||||||
DCHECK_LE(0, input_count);
|
|
||||||
node->set_op(common()->Phi(kMachInt32, input_count));
|
|
||||||
for (int i = 0; i < input_count; ++i) {
|
|
||||||
Node* value = input->InputAt(i);
|
|
||||||
// Recursively try to reduce the value first.
|
|
||||||
Reduction const reduction = ReduceTruncateFloat64ToInt32Input(value);
|
|
||||||
if (reduction.Changed()) {
|
|
||||||
value = reduction.replacement();
|
|
||||||
} else {
|
|
||||||
value = graph()->NewNode(machine()->TruncateFloat64ToInt32(), value);
|
|
||||||
}
|
|
||||||
if (i < node->InputCount()) {
|
|
||||||
node->ReplaceInput(i, value);
|
|
||||||
} else {
|
|
||||||
node->AppendInput(graph()->zone(), value);
|
|
||||||
}
|
}
|
||||||
|
phi->set_op(common()->Phi(kMachInt32, value_input_count));
|
||||||
|
return Replace(phi);
|
||||||
}
|
}
|
||||||
if (input_count < node->InputCount()) {
|
|
||||||
node->ReplaceInput(input_count, control);
|
|
||||||
} else {
|
|
||||||
node->AppendInput(graph()->zone(), control);
|
|
||||||
}
|
|
||||||
node->TrimInputCount(input_count + 1);
|
|
||||||
return Changed(node);
|
|
||||||
}
|
}
|
||||||
return NoChange();
|
return NoChange();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,6 @@ class MachineOperatorReducer FINAL : public Reducer {
|
|||||||
Reduction ReduceUint32Div(Node* node);
|
Reduction ReduceUint32Div(Node* node);
|
||||||
Reduction ReduceInt32Mod(Node* node);
|
Reduction ReduceInt32Mod(Node* node);
|
||||||
Reduction ReduceUint32Mod(Node* node);
|
Reduction ReduceUint32Mod(Node* node);
|
||||||
Reduction ReduceTruncateFloat64ToInt32Input(Node* input);
|
|
||||||
Reduction ReduceTruncateFloat64ToInt32(Node* node);
|
Reduction ReduceTruncateFloat64ToInt32(Node* node);
|
||||||
Reduction ReduceStore(Node* node);
|
Reduction ReduceStore(Node* node);
|
||||||
Reduction ReduceProjection(size_t index, Node* node);
|
Reduction ReduceProjection(size_t index, Node* node);
|
||||||
|
@ -469,25 +469,6 @@ TEST_F(MachineOperatorReducerTest, TruncateFloat64ToInt32WithPhi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(MachineOperatorReducerTest,
|
|
||||||
TruncateFloat64ToInt32WithPhiAndChangeInt32ToFloat64) {
|
|
||||||
Node* const p0 = Parameter(0);
|
|
||||||
Node* const merge = graph()->start();
|
|
||||||
Node* const truncate = graph()->NewNode(
|
|
||||||
machine()->TruncateFloat64ToInt32(),
|
|
||||||
graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p0, merge));
|
|
||||||
truncate->InputAt(0)->ReplaceInput(
|
|
||||||
1, graph()->NewNode(machine()->ChangeInt32ToFloat64(), truncate));
|
|
||||||
Reduction reduction = Reduce(truncate);
|
|
||||||
ASSERT_TRUE(reduction.Changed());
|
|
||||||
Capture<Node*> phi;
|
|
||||||
EXPECT_THAT(
|
|
||||||
reduction.replacement(),
|
|
||||||
AllOf(CaptureEq(&phi), IsPhi(kMachInt32, IsTruncateFloat64ToInt32(p0),
|
|
||||||
CaptureEq(&phi), merge)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// TruncateInt64ToInt32
|
// TruncateInt64ToInt32
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user