Commit 7aa3931f authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Add constant-folding for CheckedFloat64ToInt32.

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

Review-Url: https://codereview.chromium.org/2612763002
Cr-Commit-Position: refs/heads/master@{#42060}
parent 95db8643
......@@ -129,6 +129,15 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
}
break;
}
case IrOpcode::kCheckedFloat64ToInt32: {
Float64Matcher m(node->InputAt(0));
if (m.HasValue() && IsInt32Double(m.Value())) {
Node* value = jsgraph()->Int32Constant(static_cast<int32_t>(m.Value()));
ReplaceWithValue(node, value);
return Replace(value);
}
break;
}
case IrOpcode::kCheckedTaggedToInt32:
case IrOpcode::kCheckedTaggedSignedToInt32: {
NodeMatcher m(node->InputAt(0));
......
......@@ -335,6 +335,22 @@ TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) {
}
}
// -----------------------------------------------------------------------------
// CheckedFloat64ToInt32
TEST_F(SimplifiedOperatorReducerTest, CheckedFloat64ToInt32WithConstant) {
Node* effect = graph()->start();
Node* control = graph()->start();
TRACED_FOREACH(int32_t, n, kInt32Values) {
Reduction r = Reduce(
graph()->NewNode(simplified()->CheckedFloat64ToInt32(
CheckForMinusZeroMode::kDontCheckForMinusZero),
Float64Constant(n), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsInt32Constant(n));
}
}
// -----------------------------------------------------------------------------
// CheckHeapObject
......
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