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

Unified Diff: test/cctest/compiler/test-run-machops.cc

Issue 1356913002: [turbofan] Add support for reinterpreting integers as floating point and vice versa. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename ReinterpretAs to BitcastTo Created 5 years, 3 months 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 | « src/compiler/x87/instruction-selector-x87.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2206181f19013cb6d288a84dc866a553e1d506f3..a12c383da519421b8f64a4f3316fcb9f7db5901f 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -5322,4 +5322,69 @@ TEST(RunCheckedStoreInt64) {
CHECK_EQ(write, buffer[0]);
CHECK_EQ(write, buffer[1]);
}
+
+
+TEST(RunBitcastInt64ToFloat64) {
+ // TODO(titzer): run int64 tests on all platforms when supported.
+ int64_t input = 1;
+ double output = 0.0;
+ RawMachineAssemblerTester<int32_t> m;
+ m.StoreToPointer(
+ &output, kMachFloat64,
+ m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64)));
+ m.Return(m.Int32Constant(11));
+ FOR_INT32_INPUTS(i) {
+ input = static_cast<int64_t>(*i) * 14444;
+ CHECK_EQ(11, m.Call());
+ double expected = bit_cast<double>(input);
+ CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output));
+ }
+}
+
+
+TEST(RunBitcastFloat64ToInt64) {
+ // TODO(titzer): run int64 tests on all platforms when supported.
+ double input = 0;
+ int64_t output = 0;
+ RawMachineAssemblerTester<int32_t> m;
+ m.StoreToPointer(
+ &output, kMachInt64,
+ m.BitcastFloat64ToInt64(m.LoadFromPointer(&input, kMachFloat64)));
+ m.Return(m.Int32Constant(11));
+ FOR_FLOAT64_INPUTS(i) {
+ input = *i;
+ CHECK_EQ(11, m.Call());
+ double expected = bit_cast<int64_t>(input);
+ CHECK_EQ(expected, output);
+ }
+}
#endif
+
+
+TEST(RunBitcastFloat32ToInt32) {
+ float input = 32.25;
+ RawMachineAssemblerTester<int32_t> m;
+ m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32)));
+ FOR_FLOAT32_INPUTS(i) {
+ input = *i;
+ int32_t expected = bit_cast<int32_t>(input);
+ CHECK_EQ(expected, m.Call());
+ }
+}
+
+
+TEST(RunBitcastInt32ToFloat32) {
+ int32_t input = 1;
+ float output = 0.0;
+ RawMachineAssemblerTester<int32_t> m;
+ m.StoreToPointer(
+ &output, kMachFloat32,
+ m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32)));
+ m.Return(m.Int32Constant(11));
+ FOR_INT32_INPUTS(i) {
+ input = *i;
+ CHECK_EQ(11, m.Call());
+ float expected = bit_cast<float>(input);
+ CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output));
+ }
+}
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698