Commit 107629d1 authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[compiler] Silence NaNs in Float64Mod and Float64Atan2

Looks like these may have been missed; all other related operators
silence NaNs.

Bug: v8:7519
Change-Id: If6ee8d6e02d304ccbb4821c21386f93eab225434
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2637853
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72277}
parent 4777f170
......@@ -615,10 +615,10 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
return ReplaceFloat64(std::numeric_limits<double>::quiet_NaN());
}
if (m.right().IsNaN()) { // x % NaN => NaN
return Replace(m.right().node());
return ReplaceFloat64(SilenceNaN(m.right().ResolvedValue()));
}
if (m.left().IsNaN()) { // NaN % x => NaN
return Replace(m.left().node());
return ReplaceFloat64(SilenceNaN(m.left().ResolvedValue()));
}
if (m.IsFoldable()) { // K % K => K (K stands for arbitrary constants)
return ReplaceFloat64(
......@@ -665,10 +665,10 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
case IrOpcode::kFloat64Atan2: {
Float64BinopMatcher m(node);
if (m.right().IsNaN()) {
return Replace(m.right().node());
return ReplaceFloat64(SilenceNaN(m.right().ResolvedValue()));
}
if (m.left().IsNaN()) {
return Replace(m.left().node());
return ReplaceFloat64(SilenceNaN(m.left().ResolvedValue()));
}
if (m.IsFoldable()) {
return ReplaceFloat64(base::ieee754::atan2(m.left().ResolvedValue(),
......
......@@ -2427,18 +2427,19 @@ TEST_F(MachineOperatorReducerTest, Float64Atan2WithConstant) {
TEST_F(MachineOperatorReducerTest, Float64Atan2WithNaN) {
Node* const p0 = Parameter(0);
Node* const nan = Float64Constant(std::numeric_limits<double>::quiet_NaN());
const double nan = std::numeric_limits<double>::quiet_NaN();
Node* const nan_node = Float64Constant(nan);
{
Reduction const r =
Reduce(graph()->NewNode(machine()->Float64Atan2(), p0, nan));
Reduce(graph()->NewNode(machine()->Float64Atan2(), p0, nan_node));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(nan, r.replacement());
EXPECT_THAT(r.replacement(), IsFloat64Constant(NanSensitiveDoubleEq(nan)));
}
{
Reduction const r =
Reduce(graph()->NewNode(machine()->Float64Atan2(), nan, p0));
Reduce(graph()->NewNode(machine()->Float64Atan2(), nan_node, p0));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(nan, r.replacement());
EXPECT_THAT(r.replacement(), IsFloat64Constant(NanSensitiveDoubleEq(nan)));
}
}
......
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