Index: test/cctest/compiler/test-run-machops.cc |
diff --git a/test/cctest/compiler/test-run-machops.cc b/test/cctest/compiler/test-run-machops.cc |
index 6f37e601f6def1e17630a9ebecbaacde8b3c22a2..978842bf7953884020bec2cff2daf0f494c9df6d 100644 |
--- a/test/cctest/compiler/test-run-machops.cc |
+++ b/test/cctest/compiler/test-run-machops.cc |
@@ -4245,4 +4245,74 @@ TEST(RunTruncateInt64ToInt32P) { |
} |
} |
+ |
+TEST(RunTruncateFloat64ToInt32P) { |
+ struct { |
+ double from; |
+ double raw; |
+ } kValues[] = {{0, 0}, |
+ {0.5, 0}, |
+ {-0.5, 0}, |
+ {1.5, 1}, |
+ {-1.5, -1}, |
+ {5.5, 5}, |
+ {-5.0, -5}, |
+ {v8::base::OS::nan_value(), 0}, |
+ {std::numeric_limits<double>::infinity(), 0}, |
+ {-v8::base::OS::nan_value(), 0}, |
+ {-std::numeric_limits<double>::infinity(), 0}, |
+ {4.94065645841e-324, 0}, |
+ {-4.94065645841e-324, 0}, |
+ {0.9999999999999999, 0}, |
+ {-0.9999999999999999, 0}, |
+ {4294967296.0, 0}, |
+ {-4294967296.0, 0}, |
+ {9223372036854775000.0, 4294966272.0}, |
+ {-9223372036854775000.0, -4294966272.0}, |
+ {4.5036e+15, 372629504}, |
+ {-4.5036e+15, -372629504}, |
+ {287524199.5377777, 0x11234567}, |
+ {-287524199.5377777, -0x11234567}, |
+ {2300193596.302222, 2300193596.0}, |
+ {-2300193596.302222, -2300193596.0}, |
+ {4600387192.604444, 305419896}, |
+ {-4600387192.604444, -305419896}, |
+ {4823855600872397.0, 1737075661}, |
+ {-4823855600872397.0, -1737075661}, |
+ {4503603922337791.0, -1}, |
+ {-4503603922337791.0, 1}, |
+ {4503601774854143.0, 2147483647}, |
+ {-4503601774854143.0, -2147483647}, |
+ {9007207844675582.0, -2}, |
+ {-9007207844675582.0, 2}, |
+ {2.4178527921507624e+24, -536870912}, |
+ {-2.4178527921507624e+24, 536870912}, |
+ {2.417853945072267e+24, -536870912}, |
+ {-2.417853945072267e+24, 536870912}, |
+ {4.8357055843015248e+24, -1073741824}, |
+ {-4.8357055843015248e+24, 1073741824}, |
+ {4.8357078901445341e+24, -1073741824}, |
+ {-4.8357078901445341e+24, 1073741824}, |
+ {2147483647.0, 2147483647.0}, |
+ {-2147483648.0, -2147483648.0}, |
+ {9.6714111686030497e+24, -2147483648.0}, |
+ {-9.6714111686030497e+24, -2147483648.0}, |
+ {9.6714157802890681e+24, -2147483648.0}, |
+ {-9.6714157802890681e+24, -2147483648.0}, |
+ {1.9342813113834065e+25, 2147483648.0}, |
+ {-1.9342813113834065e+25, 2147483648.0}, |
+ {3.868562622766813e+25, 0}, |
+ {-3.868562622766813e+25, 0}, |
+ {1.7976931348623157e+308, 0}, |
+ {-1.7976931348623157e+308, 0}}; |
+ double input = -1.0; |
+ RawMachineAssemblerTester<int32_t> m; |
+ m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); |
+ for (size_t i = 0; i < ARRAY_SIZE(kValues); ++i) { |
+ input = kValues[i].from; |
+ uint64_t expected = static_cast<int64_t>(kValues[i].raw); |
+ CHECK_EQ(static_cast<int>(expected), m.Call()); |
+ } |
+} |
+ |
#endif // V8_TURBOFAN_TARGET |