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

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

Issue 555833002: [turbofan] Add support for overflow add/sub to the MachineOperatorReducer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address nit. Created 6 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/machine-operator-reducer-unittest.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 4841bbb1b6954d98c7b23efd1194ae66e4b012e0..4c3ed4db8d0adf8b23958ae6d2eb3809e3212981 100644
--- a/test/cctest/compiler/test-run-machops.cc
+++ b/test/cctest/compiler/test-run-machops.cc
@@ -4016,22 +4016,6 @@ TEST(RunSpillLotsOfThingsWithCall) {
#endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C
-static bool sadd_overflow(int32_t x, int32_t y, int32_t* val) {
- int32_t v =
- static_cast<int32_t>(static_cast<uint32_t>(x) + static_cast<uint32_t>(y));
- *val = v;
- return (((v ^ x) & (v ^ y)) >> 31) & 1;
-}
-
-
-static bool ssub_overflow(int32_t x, int32_t y, int32_t* val) {
- int32_t v =
- static_cast<int32_t>(static_cast<uint32_t>(x) - static_cast<uint32_t>(y));
- *val = v;
- return (((v ^ x) & (v ^ ~y)) >> 31) & 1;
-}
-
-
TEST(RunInt32AddWithOverflowP) {
int32_t actual_val = -1;
RawMachineAssemblerTester<int32_t> m;
@@ -4044,7 +4028,7 @@ TEST(RunInt32AddWithOverflowP) {
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
int32_t expected_val;
- int expected_ovf = sadd_overflow(*i, *j, &expected_val);
+ int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
CHECK_EQ(expected_ovf, bt.call(*i, *j));
CHECK_EQ(expected_val, actual_val);
}
@@ -4063,7 +4047,7 @@ TEST(RunInt32AddWithOverflowImm) {
m.StoreToPointer(&actual_val, kMachInt32, val);
m.Return(ovf);
FOR_INT32_INPUTS(j) {
- int expected_ovf = sadd_overflow(*i, *j, &expected_val);
+ int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
CHECK_EQ(expected_ovf, m.Call(*j));
CHECK_EQ(expected_val, actual_val);
}
@@ -4076,7 +4060,7 @@ TEST(RunInt32AddWithOverflowImm) {
m.StoreToPointer(&actual_val, kMachInt32, val);
m.Return(ovf);
FOR_INT32_INPUTS(j) {
- int expected_ovf = sadd_overflow(*i, *j, &expected_val);
+ int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
CHECK_EQ(expected_ovf, m.Call(*j));
CHECK_EQ(expected_val, actual_val);
}
@@ -4089,7 +4073,7 @@ TEST(RunInt32AddWithOverflowImm) {
Node* ovf = m.Projection(1, add);
m.StoreToPointer(&actual_val, kMachInt32, val);
m.Return(ovf);
- int expected_ovf = sadd_overflow(*i, *j, &expected_val);
+ int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
CHECK_EQ(expected_ovf, m.Call());
CHECK_EQ(expected_val, actual_val);
}
@@ -4113,7 +4097,7 @@ TEST(RunInt32AddWithOverflowInBranchP) {
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
int32_t expected;
- if (sadd_overflow(*i, *j, &expected)) expected = constant;
+ if (bits::SignedAddOverflow32(*i, *j, &expected)) expected = constant;
CHECK_EQ(expected, bt.call(*i, *j));
}
}
@@ -4132,7 +4116,7 @@ TEST(RunInt32SubWithOverflowP) {
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
int32_t expected_val;
- int expected_ovf = ssub_overflow(*i, *j, &expected_val);
+ int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
CHECK_EQ(expected_ovf, bt.call(*i, *j));
CHECK_EQ(expected_val, actual_val);
}
@@ -4151,7 +4135,7 @@ TEST(RunInt32SubWithOverflowImm) {
m.StoreToPointer(&actual_val, kMachInt32, val);
m.Return(ovf);
FOR_INT32_INPUTS(j) {
- int expected_ovf = ssub_overflow(*i, *j, &expected_val);
+ int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
CHECK_EQ(expected_ovf, m.Call(*j));
CHECK_EQ(expected_val, actual_val);
}
@@ -4164,7 +4148,7 @@ TEST(RunInt32SubWithOverflowImm) {
m.StoreToPointer(&actual_val, kMachInt32, val);
m.Return(ovf);
FOR_INT32_INPUTS(j) {
- int expected_ovf = ssub_overflow(*j, *i, &expected_val);
+ int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val);
CHECK_EQ(expected_ovf, m.Call(*j));
CHECK_EQ(expected_val, actual_val);
}
@@ -4177,7 +4161,7 @@ TEST(RunInt32SubWithOverflowImm) {
Node* ovf = m.Projection(1, add);
m.StoreToPointer(&actual_val, kMachInt32, val);
m.Return(ovf);
- int expected_ovf = ssub_overflow(*i, *j, &expected_val);
+ int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
CHECK_EQ(expected_ovf, m.Call());
CHECK_EQ(expected_val, actual_val);
}
@@ -4201,7 +4185,7 @@ TEST(RunInt32SubWithOverflowInBranchP) {
FOR_INT32_INPUTS(i) {
FOR_INT32_INPUTS(j) {
int32_t expected;
- if (ssub_overflow(*i, *j, &expected)) expected = constant;
+ if (bits::SignedSubOverflow32(*i, *j, &expected)) expected = constant;
CHECK_EQ(expected, bt.call(*i, *j));
}
}
« no previous file with comments | « src/compiler/machine-operator-reducer-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698