Commit c1a0e856 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Add constant-folding for Float64RoundDown.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2616613002
Cr-Commit-Position: refs/heads/master@{#42058}
parent d946a27e
......@@ -664,6 +664,8 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
case IrOpcode::kFloat64LessThan:
case IrOpcode::kFloat64LessThanOrEqual:
return ReduceFloat64Compare(node);
case IrOpcode::kFloat64RoundDown:
return ReduceFloat64RoundDown(node);
default:
break;
}
......@@ -1391,6 +1393,14 @@ Reduction MachineOperatorReducer::ReduceFloat64Compare(Node* node) {
return NoChange();
}
Reduction MachineOperatorReducer::ReduceFloat64RoundDown(Node* node) {
DCHECK_EQ(IrOpcode::kFloat64RoundDown, node->opcode());
Float64Matcher m(node->InputAt(0));
if (m.HasValue()) {
return ReplaceFloat64(Floor(m.Value()));
}
return NoChange();
}
CommonOperatorBuilder* MachineOperatorReducer::common() const {
return jsgraph()->common();
......
......@@ -96,6 +96,7 @@ class V8_EXPORT_PRIVATE MachineOperatorReducer final
Reduction ReduceFloat64InsertLowWord32(Node* node);
Reduction ReduceFloat64InsertHighWord32(Node* node);
Reduction ReduceFloat64Compare(Node* node);
Reduction ReduceFloat64RoundDown(Node* node);
Graph* graph() const;
JSGraph* jsgraph() const { return jsgraph_; }
......
......@@ -2085,8 +2085,19 @@ TEST_F(MachineOperatorReducerTest, Float64LessThanOrEqualWithFloat32Constant) {
// -----------------------------------------------------------------------------
// Store
// Float64RoundDown
TEST_F(MachineOperatorReducerTest, Float64RoundDownWithConstant) {
TRACED_FOREACH(double, x, kFloat64Values) {
Reduction r = Reduce(graph()->NewNode(
machine()->Float64RoundDown().placeholder(), Float64Constant(x)));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFloat64Constant(Floor(x)));
}
}
// -----------------------------------------------------------------------------
// Store
TEST_F(MachineOperatorReducerTest, StoreRepWord8WithWord32And) {
const StoreRepresentation rep(MachineRepresentation::kWord8, kNoWriteBarrier);
......
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