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

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

Issue 431473004: TF: Add ConvertFloat64ToUint32 and ConvertUint32ToFloat64 machine operators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/x64/instruction-selector-x64.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 a4f915653fc150c928a80a69392557206e472366..1c9f89a3f53827908ad3aa84ee7030c049154e0f 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -2888,7 +2888,21 @@ TEST(RunConvertInt32ToFloat64_B) {
}
-// TODO(titzer): Test ConvertUint32ToFloat64
+TEST(RunConvertUint32ToFloat64_B) {
+ RawMachineAssemblerTester<int32_t> m(kMachineWord32);
+ double output = 0;
+
+ Node* convert = m.ConvertUint32ToFloat64(m.Parameter(0));
+ m.Store(kMachineFloat64, m.PointerConstant(&output), m.Int32Constant(0),
+ convert);
+ m.Return(m.Parameter(0));
+
+ FOR_UINT32_INPUTS(i) {
+ uint32_t expect = *i;
+ CHECK_EQ(expect, m.Call(expect));
+ CHECK_EQ(static_cast<double>(expect), output);
+ }
+}
TEST(RunConvertFloat64ToInt32_A) {
@@ -2921,49 +2935,73 @@ TEST(RunConvertFloat64ToInt32_B) {
{
FOR_INT32_INPUTS(i) {
input = *i;
- int expect = *i;
+ int32_t expect = *i;
CHECK_EQ(expect, m.Call());
CHECK_EQ(expect, output);
}
}
- {
- FOR_FLOAT64_INPUTS(i) {
- input = *i;
- // TODO(titzer): float64 -> int32 outside of the int32 range; the machine
- // backends are all wrong in different ways, and they certainly don't
- // implement the JavaScript conversions correctly.
- if (std::isnan(input) || input > INT_MAX || input < INT_MIN) {
- continue;
- }
- int32_t expect = static_cast<int32_t>(input);
+ // Check various powers of 2.
+ for (int32_t n = 1; n < 31; ++n) {
+ {
+ input = 1 << n;
+ int32_t expect = input;
+ CHECK_EQ(expect, m.Call());
+ CHECK_EQ(expect, output);
+ }
+
+ {
+ input = 3 << n;
+ int32_t expect = input;
CHECK_EQ(expect, m.Call());
CHECK_EQ(expect, output);
}
}
+ // Note we don't check fractional inputs, because these Convert operators
+ // really should be Change operators.
}
-// TODO(titzer): test ConvertFloat64ToUint32
-
-
-TEST(RunConvertFloat64ToInt32_truncation) {
+TEST(RunConvertFloat64ToUint32_B) {
RawMachineAssemblerTester<int32_t> m;
- int32_t magic = 0x786234;
- double input = 3.9;
- int32_t result = 0;
+ double input = 0;
+ int32_t output = 0;
- Node* input_node =
+ Node* load =
m.Load(kMachineFloat64, m.PointerConstant(&input), m.Int32Constant(0));
- m.Store(kMachineWord32, m.PointerConstant(&result), m.Int32Constant(0),
- m.ConvertFloat64ToInt32(input_node));
- m.Return(m.Int32Constant(magic));
+ Node* convert = m.ConvertFloat64ToUint32(load);
+ m.Store(kMachineWord32, m.PointerConstant(&output), m.Int32Constant(0),
+ convert);
+ m.Return(convert);
- for (int i = -200; i < 200; i++) {
- input = i + (i < 0 ? -0.9 : 0.9);
- CHECK_EQ(magic, m.Call());
- CHECK_EQ(i, result);
+ {
+ FOR_UINT32_INPUTS(i) {
+ input = *i;
+ // TODO(titzer): add a CheckEqualsHelper overload for uint32_t.
+ int32_t expect = static_cast<int32_t>(*i);
+ CHECK_EQ(expect, m.Call());
+ CHECK_EQ(expect, output);
+ }
+ }
+
+ // Check various powers of 2.
+ for (int32_t n = 1; n < 31; ++n) {
+ {
+ input = 1u << n;
+ int32_t expect = static_cast<int32_t>(static_cast<uint32_t>(input));
+ CHECK_EQ(expect, m.Call());
+ CHECK_EQ(expect, output);
+ }
+
+ {
+ input = 3u << n;
+ int32_t expect = static_cast<int32_t>(static_cast<uint32_t>(input));
+ CHECK_EQ(expect, m.Call());
+ CHECK_EQ(expect, output);
+ }
}
+ // Note we don't check fractional inputs, because these Convert operators
+ // really should be Change operators.
}
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698