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

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

Issue 1778893005: [wasm] Int64Lowering of Int64Sub on ia32 and arm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@wasm-add
Patch Set: Rebase. Created 4 years, 9 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') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | 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 89f3875aa8768c2d2f82d67bb096eee66b6e39f6..5c85325f8bc7623b553d351514fbabfc8f1b95c7 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -4197,16 +4197,16 @@ 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);
+uint64_t ToInt64(uint32_t low, uint32_t high) {
+ return (static_cast<uint64_t>(high) << 32) | static_cast<uint64_t>(low);
}
#if V8_TARGET_ARCH_32_BIT && !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_PPC && \
!V8_TARGET_ARCH_X87
TEST(RunInt32PairAdd) {
BufferedRawMachineAssemblerTester<int32_t> m(
- MachineType::Int32(), MachineType::Int32(), MachineType::Int32(),
- MachineType::Int32());
+ MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
+ MachineType::Uint32());
uint32_t high;
uint32_t low;
@@ -4220,12 +4220,12 @@ TEST(RunInt32PairAdd) {
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));
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ m.Call(static_cast<uint32_t>(*i & 0xffffffff),
+ static_cast<uint32_t>(*i >> 32),
+ static_cast<uint32_t>(*j & 0xffffffff),
+ static_cast<uint32_t>(*j >> 32));
CHECK_EQ(*i + *j, ToInt64(low, high));
}
}
@@ -4266,6 +4266,69 @@ TEST(RunInt32PairAddWithSharedInput) {
TestInt32PairAddWithSharedInput(1, 1, 0, 0);
}
+TEST(RunInt32PairSub) {
+ BufferedRawMachineAssemblerTester<int32_t> m(
+ MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairSub = m.Int32PairSub(m.Parameter(0), m.Parameter(1), m.Parameter(2),
+ m.Parameter(3));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairSub));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairSub));
+ m.Return(m.Int32Constant(74));
+
+ FOR_UINT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(j) {
+ m.Call(static_cast<uint32_t>(*i & 0xffffffff),
+ static_cast<uint32_t>(*i >> 32),
+ static_cast<uint32_t>(*j & 0xffffffff),
+ static_cast<uint32_t>(*j >> 32));
+ CHECK_EQ(*i - *j, ToInt64(low, high));
+ }
+ }
+}
+
+void TestInt32PairSubWithSharedInput(int a, int b, int c, int d) {
+ BufferedRawMachineAssemblerTester<int32_t> m(MachineType::Uint32(),
+ MachineType::Uint32());
+
+ uint32_t high;
+ uint32_t low;
+
+ Node* PairSub = m.Int32PairSub(m.Parameter(a), m.Parameter(b), m.Parameter(c),
+ m.Parameter(d));
+
+ m.StoreToPointer(&low, MachineRepresentation::kWord32,
+ m.Projection(0, PairSub));
+ m.StoreToPointer(&high, MachineRepresentation::kWord32,
+ m.Projection(1, PairSub));
+ 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(RunInt32PairSubWithSharedInput) {
+ TestInt32PairSubWithSharedInput(0, 0, 0, 0);
+ TestInt32PairSubWithSharedInput(1, 0, 0, 0);
+ TestInt32PairSubWithSharedInput(0, 1, 0, 0);
+ TestInt32PairSubWithSharedInput(0, 0, 1, 0);
+ TestInt32PairSubWithSharedInput(0, 0, 0, 1);
+ TestInt32PairSubWithSharedInput(1, 1, 0, 0);
+}
+
TEST(RunWord32PairShl) {
BufferedRawMachineAssemblerTester<int32_t> m(
MachineType::Uint32(), MachineType::Uint32(), MachineType::Uint32());
@@ -4282,7 +4345,7 @@ TEST(RunWord32PairShl) {
m.Projection(1, PairAdd));
m.Return(m.Int32Constant(74));
- FOR_INT64_INPUTS(i) {
+ FOR_UINT64_INPUTS(i) {
for (uint32_t j = 0; j < 64; j++) {
m.Call(static_cast<uint32_t>(*i & 0xffffffff),
static_cast<uint32_t>(*i >> 32), j);
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698