Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1482)

Unified Diff: test/unittests/compiler/machine-operator-reducer-unittest.cc

Issue 1433353006: [machine-operator-reducer] fix float truncation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix typo Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/math-52-mul-div.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/machine-operator-reducer-unittest.cc
diff --git a/test/unittests/compiler/machine-operator-reducer-unittest.cc b/test/unittests/compiler/machine-operator-reducer-unittest.cc
index 6f7ed3aca48df98ad15a36510582cb44563a85b6..9e1ed6efdc0aee8e0eef8d3378d214cd424b3124 100644
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc
@@ -1649,13 +1649,34 @@ TEST_F(MachineOperatorReducerTest, StoreRepWord16WithWord32SarAndWord32Shl) {
TEST_F(MachineOperatorReducerTest, RoundPlusTruncate) {
Node* p0 = Parameter(0);
+
+ Type* p0_range = Type::Range(0x0, 0xFFFFFF8000001ULL, graph()->zone());
+ NodeProperties::SetType(
+ p0, Type::Intersect(p0_range, Type::Number(), graph()->zone()));
+
Node* t0 = graph()->NewNode(machine()->RoundInt64ToFloat64(), p0);
Node* t1 = graph()->NewNode(
machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript), t0);
Reduction r = Reduce(t1);
ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), p0);
+ EXPECT_THAT(r.replacement(), IsTruncateInt64ToInt32(p0));
+}
+
+
+TEST_F(MachineOperatorReducerTest, OverflowingRoundPlusTruncate) {
+ Node* p0 = Parameter(0);
+
+ Type* p0_range = Type::Range(0x0, 0x10000000000000ULL, graph()->zone());
+ NodeProperties::SetType(
+ p0, Type::Intersect(p0_range, Type::Number(), graph()->zone()));
+
+ Node* t0 = graph()->NewNode(machine()->RoundInt64ToFloat64(), p0);
+ Node* t1 = graph()->NewNode(
+ machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript), t0);
+
+ Reduction r = Reduce(t1);
+ ASSERT_TRUE(!r.Changed());
}
} // namespace compiler
« no previous file with comments | « test/mjsunit/math-52-mul-div.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698