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 a7581906ff9f0b2160f69ea1e83ce9492effad03..13bce4a612540875270900c2088df2684d84c6a8 100644 |
--- a/test/cctest/compiler/test-run-machops.cc |
+++ b/test/cctest/compiler/test-run-machops.cc |
@@ -4197,6 +4197,74 @@ TEST(RunTruncateFloat64ToFloat32) { |
FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(DoubleToFloat32(*i), m.Call(*i)); } |
} |
+int64_t ToInt64(uint32_t low, uint32_t high) { |
+ return (static_cast<int64_t>(high) << 32) | static_cast<int64_t>(low); |
+} |
+ |
+#if V8_TARGET_ARCH_32_BIT |
+TEST(RunInt32PairAdd) { |
+ BufferedRawMachineAssemblerTester<int32_t> m( |
+ MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), |
+ MachineType::Int32()); |
+ |
+ uint32_t high; |
+ uint32_t low; |
+ |
+ Node* PairAdd = m.Int32PairAdd(m.Parameter(0), m.Parameter(1), m.Parameter(2), |
+ m.Parameter(3)); |
+ |
+ m.StoreToPointer(&low, MachineRepresentation::kWord32, |
+ m.Projection(0, PairAdd)); |
+ m.StoreToPointer(&high, MachineRepresentation::kWord32, |
+ m.Projection(1, PairAdd)); |
+ m.Return(m.Int32Constant(74)); |
+ |
+ FOR_INT64_INPUTS(i) { |
+ FOR_INT64_INPUTS(j) { |
+ m.Call(static_cast<int32_t>(*i & 0xffffffff), |
+ static_cast<int32_t>(*i >> 32), |
+ static_cast<int32_t>(*j & 0xffffffff), |
+ static_cast<int32_t>(*j >> 32)); |
+ CHECK_EQ(*i + *j, ToInt64(low, high)); |
+ } |
+ } |
+} |
+ |
+void TestInt32PairAddWithSharedInput(int a, int b, int c, int d) { |
+ BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(), |
+ MachineType::Uint32()); |
+ |
+ uint32_t high; |
+ uint32_t low; |
+ |
+ Node* PairAdd = m.Int32PairAdd(m.Parameter(a), m.Parameter(b), m.Parameter(c), |
+ m.Parameter(d)); |
+ |
+ m.StoreToPointer(&low, MachineRepresentation::kWord32, |
+ m.Projection(0, PairAdd)); |
+ m.StoreToPointer(&high, MachineRepresentation::kWord32, |
+ m.Projection(1, PairAdd)); |
+ m.Return(m.Int32Constant(74)); |
+ |
+ FOR_UINT32_INPUTS(i) { |
+ FOR_UINT32_INPUTS(j) { |
+ m.Call(*i, *j); |
+ uint32_t inputs[] = {*i, *j}; |
+ CHECK_EQ(ToInt64(inputs[a], inputs[b]) + ToInt64(inputs[c], inputs[d]), |
+ ToInt64(low, high)); |
+ } |
+ } |
+} |
+ |
+TEST(RunInt32PairAddWithSharedInput) { |
+ TestInt32PairAddWithSharedInput(0, 0, 0, 0); |
+ TestInt32PairAddWithSharedInput(1, 0, 0, 0); |
+ TestInt32PairAddWithSharedInput(0, 1, 0, 0); |
+ TestInt32PairAddWithSharedInput(0, 0, 1, 0); |
+ TestInt32PairAddWithSharedInput(0, 0, 0, 1); |
+ TestInt32PairAddWithSharedInput(1, 1, 0, 0); |
+} |
+#endif |
TEST(RunDeadChangeFloat64ToInt32) { |
RawMachineAssemblerTester<int32_t> m; |