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

Unified Diff: runtime/vm/intermediate_language_test.cc

Issue 328503003: Extend Range analysis to 64-bit range and mint operations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_test.cc
diff --git a/runtime/vm/intermediate_language_test.cc b/runtime/vm/intermediate_language_test.cc
index 8400557f03afff8c26a9816fe4b6c83ef683b932..883a512c7a29ab0a1b774792d880c4657ea84889 100644
--- a/runtime/vm/intermediate_language_test.cc
+++ b/runtime/vm/intermediate_language_test.cc
@@ -53,7 +53,6 @@ TEST_CASE(RangeTests) {
Range* range_x = new Range(
RangeBoundary::FromConstant(-15),
RangeBoundary::FromConstant(100));
- EXPECT(negative->IsNegative());
EXPECT(positive->IsPositive());
EXPECT(zero->Overlaps(0, 0));
EXPECT(positive->Overlaps(0, 0));
@@ -119,8 +118,11 @@ TEST_CASE(RangeTests) {
TEST_CASE(RangeTestsInfinity) {
// +/- inf overflowed.
- EXPECT(RangeBoundary::NegativeInfinity().Overflowed());
- EXPECT(RangeBoundary::PositiveInfinity().Overflowed());
+ EXPECT(RangeBoundary::NegativeInfinity().OverflowedSmi());
+ EXPECT(RangeBoundary::PositiveInfinity().OverflowedSmi());
+
+ EXPECT(RangeBoundary::NegativeInfinity().OverflowedMint());
+ EXPECT(RangeBoundary::PositiveInfinity().OverflowedMint());
Range* all = new Range(RangeBoundary::NegativeInfinity(),
RangeBoundary::PositiveInfinity());
@@ -130,14 +132,12 @@ TEST_CASE(RangeTestsInfinity) {
Range* positive = new Range(RangeBoundary::FromConstant(0),
RangeBoundary::PositiveInfinity());
EXPECT(positive->IsPositive());
- EXPECT(!positive->IsNegative());
EXPECT(positive->Overlaps(0, 1));
EXPECT(positive->Overlaps(1, 100));
EXPECT(positive->Overlaps(-1, 0));
EXPECT(!positive->Overlaps(-2, -1));
Range* negative = new Range(RangeBoundary::NegativeInfinity(),
RangeBoundary::FromConstant(-1));
- EXPECT(negative->IsNegative());
EXPECT(!negative->IsPositive());
EXPECT(!negative->Overlaps(0, 1));
EXPECT(!negative->Overlaps(1, 100));
@@ -145,7 +145,6 @@ TEST_CASE(RangeTestsInfinity) {
EXPECT(negative->Overlaps(-2, -1));
Range* negpos = new Range(RangeBoundary::NegativeInfinity(),
RangeBoundary::FromConstant(0));
- EXPECT(!negpos->IsNegative());
EXPECT(!negpos->IsPositive());
Range* a = new Range(RangeBoundary::NegativeInfinity(),
@@ -174,4 +173,480 @@ TEST_CASE(RangeTestsInfinity) {
EXPECT(unsatisfiable_left->IsUnsatisfiable());
}
+
+TEST_CASE(RangeUtils) {
+ // [-inf, +inf].
+ const Range& range_0 = *(new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::PositiveInfinity()));
+ // [-inf, -1].
+ const Range& range_a = *(new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(-1)));
+ // [-inf, 0].
+ const Range& range_b = *(new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(0)));
+ // [-inf, 1].
+ const Range& range_c = *(new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(1)));
+ // [-1, +inf]
+ const Range& range_d = *(new Range(RangeBoundary::FromConstant(-1),
+ RangeBoundary::PositiveInfinity()));
+ // [0, +inf]
+ const Range& range_e = *(new Range(RangeBoundary::FromConstant(0),
+ RangeBoundary::PositiveInfinity()));
+ // [1, +inf].
+ const Range& range_f = *(new Range(RangeBoundary::FromConstant(1),
+ RangeBoundary::PositiveInfinity()));
+ // [1, 2].
+ const Range& range_g = *(new Range(RangeBoundary::FromConstant(1),
+ RangeBoundary::FromConstant(2)));
+ // [-1, -2].
+ const Range& range_h = *(new Range(RangeBoundary::FromConstant(-1),
+ RangeBoundary::FromConstant(-2)));
+ // [-1, 1].
+ const Range& range_i = *(new Range(RangeBoundary::FromConstant(-1),
+ RangeBoundary::FromConstant(1)));
+
+ // OnlyPositiveOrZero.
+ EXPECT(!Range::OnlyPositiveOrZero(range_a, range_b));
+ EXPECT(!Range::OnlyPositiveOrZero(range_b, range_c));
+ EXPECT(!Range::OnlyPositiveOrZero(range_c, range_d));
+ EXPECT(!Range::OnlyPositiveOrZero(range_d, range_e));
+ EXPECT(Range::OnlyPositiveOrZero(range_e, range_f));
+ EXPECT(!Range::OnlyPositiveOrZero(range_d, range_d));
+ EXPECT(Range::OnlyPositiveOrZero(range_e, range_e));
+ EXPECT(Range::OnlyPositiveOrZero(range_f, range_g));
+ EXPECT(!Range::OnlyPositiveOrZero(range_g, range_h));
+ EXPECT(!Range::OnlyPositiveOrZero(range_i, range_i));
+
+ // OnlyNegativeOrZero.
+ EXPECT(Range::OnlyNegativeOrZero(range_a, range_b));
+ EXPECT(!Range::OnlyNegativeOrZero(range_b, range_c));
+ EXPECT(Range::OnlyNegativeOrZero(range_b, range_b));
+ EXPECT(!Range::OnlyNegativeOrZero(range_c, range_c));
+ EXPECT(!Range::OnlyNegativeOrZero(range_c, range_d));
+ EXPECT(!Range::OnlyNegativeOrZero(range_d, range_e));
+ EXPECT(!Range::OnlyNegativeOrZero(range_e, range_f));
+ EXPECT(!Range::OnlyNegativeOrZero(range_f, range_g));
+ EXPECT(!Range::OnlyNegativeOrZero(range_g, range_h));
+ EXPECT(Range::OnlyNegativeOrZero(range_h, range_h));
+ EXPECT(!Range::OnlyNegativeOrZero(range_i, range_i));
+
+ // [-inf, +inf].
+ EXPECT(!Range::OnlyNegativeOrZero(range_0, range_0));
+ EXPECT(!Range::OnlyPositiveOrZero(range_0, range_0));
+
+ EXPECT(Range::ConstantAbsMax(&range_0) == RangeBoundary::kMax);
+ EXPECT(Range::ConstantAbsMax(&range_h) == 2);
+ EXPECT(Range::ConstantAbsMax(&range_i) == 1);
+
+ // RangeBOundary.Equals.
+ EXPECT(RangeBoundary::FromConstant(1).Equals(
+ RangeBoundary::FromConstant(1)));
+ EXPECT(!RangeBoundary::FromConstant(2).Equals(
+ RangeBoundary::FromConstant(1)));
+ EXPECT(RangeBoundary::PositiveInfinity().Equals(
+ RangeBoundary::PositiveInfinity()));
+ EXPECT(!RangeBoundary::PositiveInfinity().Equals(
+ RangeBoundary::NegativeInfinity()));
+ EXPECT(RangeBoundary::NegativeInfinity().Equals(
+ RangeBoundary::NegativeInfinity()));
+ EXPECT(!RangeBoundary::NegativeInfinity().Equals(
+ RangeBoundary::PositiveInfinity()));
+ EXPECT(!RangeBoundary::FromConstant(1).Equals(
+ RangeBoundary::NegativeInfinity()));
+ EXPECT(!RangeBoundary::FromConstant(1).Equals(
+ RangeBoundary::NegativeInfinity()));
+ EXPECT(!RangeBoundary::FromConstant(2).Equals(
+ RangeBoundary::PositiveInfinity()));
+}
+
+
+TEST_CASE(RangeBinaryOp) {
+ Range* range_a = new Range(RangeBoundary::FromConstant(-1),
+ RangeBoundary::PositiveInfinity());
+ range_a->Clamp(RangeBoundary::kRangeBoundaryInt64);
+ EXPECT(range_a->min().ConstantValue() == -1);
+ EXPECT(range_a->max().ConstantValue() == RangeBoundary::kMax);
+ Range* range_b = new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(1));
+ range_b->Clamp(RangeBoundary::kRangeBoundaryInt64);
+ EXPECT(range_b->min().ConstantValue() == RangeBoundary::kMin);
+ EXPECT(range_b->max().ConstantValue() == 1);
+ Range* result = Range::BinaryOp(Token::kADD,
+ range_a,
+ range_b,
+ NULL);
+ ASSERT(result != NULL);
+ EXPECT(result->min().IsNegativeInfinity());
+ EXPECT(result->max().IsPositiveInfinity());
+
+ // Test that [5, 10] + [0, 5] = [5, 15].
+ Range* range_c = new Range(RangeBoundary::FromConstant(5),
+ RangeBoundary::FromConstant(10));
+ Range* range_d = new Range(RangeBoundary::FromConstant(0),
+ RangeBoundary::FromConstant(5));
+ result = Range::BinaryOp(Token::kADD,
+ range_c,
+ range_d,
+ NULL);
+ ASSERT(result != NULL);
+ EXPECT(result->min().ConstantValue() == 5);
+ EXPECT(result->max().ConstantValue() == 15);
+
+
+ // Test that [0xff, 0xfff] & [0xf, 0xf] = [0x0, 0xf].
+ Range* range_e = new Range(RangeBoundary::FromConstant(0xff),
+ RangeBoundary::FromConstant(0xfff));
+ Range* range_f = new Range(RangeBoundary::FromConstant(0xf),
+ RangeBoundary::FromConstant(0xf));
+ result = Range::BinaryOp(Token::kBIT_AND,
+ range_e,
+ range_f,
+ NULL);
+ ASSERT(result != NULL);
+ EXPECT(result->min().ConstantValue() == 0x0);
+ EXPECT(result->max().ConstantValue() == 0xf);
+}
+
+
+TEST_CASE(RangeAdd) {
+#define TEST_RANGE_ADD(l_min, l_max, r_min, r_max, result_min, result_max) \
+ { \
+ RangeBoundary min, max; \
+ Range* left_range = new Range( \
+ RangeBoundary::FromConstant(l_min), \
+ RangeBoundary::FromConstant(l_max)); \
+ Range* right_range = new Range( \
+ RangeBoundary::FromConstant(r_min), \
+ RangeBoundary::FromConstant(r_max)); \
+ EXPECT(left_range->min().ConstantValue() == l_min); \
+ EXPECT(left_range->max().ConstantValue() == l_max); \
+ EXPECT(right_range->min().ConstantValue() == r_min); \
+ EXPECT(right_range->max().ConstantValue() == r_max); \
+ Range::Add(left_range, right_range, &min, &max, NULL); \
+ EXPECT(min.Equals(result_min)); \
+ if (!min.Equals(result_min)) { \
+ OS::Print("%s != %s\n", min.ToCString(), result_min.ToCString()); \
+ } \
+ EXPECT(max.Equals(result_max)); \
+ if (!max.Equals(result_max)) { \
+ OS::Print("%s != %s\n", max.ToCString(), result_max.ToCString()); \
+ } \
+ }
+
+ // [kMaxInt32, kMaxInt32 + 15] + [10, 20] = [kMaxInt32 + 10, kMaxInt32 + 35].
+ TEST_RANGE_ADD(static_cast<int64_t>(kMaxInt32),
+ static_cast<int64_t>(kMaxInt32) + 15,
+ static_cast<int64_t>(10),
+ static_cast<int64_t>(20),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) + 10),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) + 35));
+
+ // [kMaxInt32 - 15, kMaxInt32 + 15] + [15, -15] = [kMaxInt32, kMaxInt32].
+ TEST_RANGE_ADD(static_cast<int64_t>(kMaxInt32) - 15,
+ static_cast<int64_t>(kMaxInt32) + 15,
+ static_cast<int64_t>(15),
+ static_cast<int64_t>(-15),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32)),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32)));
+
+ // [kMaxInt32, kMaxInt32 + 15] + [10, kMaxInt64] = [kMaxInt32 + 10, +inf].
+ TEST_RANGE_ADD(static_cast<int64_t>(kMaxInt32),
+ static_cast<int64_t>(kMaxInt32) + 15,
+ static_cast<int64_t>(10),
+ static_cast<int64_t>(kMaxInt64),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) + 10),
+ RangeBoundary::PositiveInfinity());
+
+ // [kMinInt64, kMaxInt32 + 15] + [10, 20] = [kMinInt64 + 10, kMaxInt32 + 35].
+ TEST_RANGE_ADD(static_cast<int64_t>(kMinInt64),
+ static_cast<int64_t>(kMaxInt32) + 15,
+ static_cast<int64_t>(10),
+ static_cast<int64_t>(20),
+ RangeBoundary(static_cast<int64_t>(kMinInt64) + 10),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) + 35));
+
+ // [0, 0] + [kMinInt64, kMaxInt64] = [kMinInt64, kMaxInt64].
+ TEST_RANGE_ADD(static_cast<int64_t>(0),
+ static_cast<int64_t>(0),
+ static_cast<int64_t>(kMinInt64),
+ static_cast<int64_t>(kMaxInt64),
+ RangeBoundary(kMinInt64),
+ RangeBoundary(kMaxInt64));
+
+ // Overflows.
+
+ // [-1, 1] + [kMinInt64, kMaxInt64] = [-inf, +inf].
+ TEST_RANGE_ADD(static_cast<int64_t>(-1),
+ static_cast<int64_t>(1),
+ static_cast<int64_t>(kMinInt64),
+ static_cast<int64_t>(kMaxInt64),
+ RangeBoundary::NegativeInfinity(),
+ RangeBoundary::PositiveInfinity());
+
+ // [kMaxInt64, kMaxInt64] + [kMaxInt64, kMaxInt64] = [-inf, +inf].
+ TEST_RANGE_ADD(static_cast<int64_t>(kMaxInt64),
+ static_cast<int64_t>(kMaxInt64),
+ static_cast<int64_t>(kMaxInt64),
+ static_cast<int64_t>(kMaxInt64),
+ RangeBoundary::NegativeInfinity(),
+ RangeBoundary::PositiveInfinity());
+
+ // [kMaxInt64, kMaxInt64] + [1, 1] = [-inf, +inf].
+ TEST_RANGE_ADD(static_cast<int64_t>(kMaxInt64),
+ static_cast<int64_t>(kMaxInt64),
+ static_cast<int64_t>(1),
+ static_cast<int64_t>(1),
+ RangeBoundary::NegativeInfinity(),
+ RangeBoundary::PositiveInfinity());
+
+#undef TEST_RANGE_ADD
+}
+
+
+TEST_CASE(RangeSub) {
+#define TEST_RANGE_SUB(l_min, l_max, r_min, r_max, result_min, result_max) \
+ { \
+ RangeBoundary min, max; \
+ Range* left_range = new Range( \
+ RangeBoundary::FromConstant(l_min), \
+ RangeBoundary::FromConstant(l_max)); \
+ Range* right_range = new Range( \
+ RangeBoundary::FromConstant(r_min), \
+ RangeBoundary::FromConstant(r_max)); \
+ EXPECT(left_range->min().ConstantValue() == l_min); \
+ EXPECT(left_range->max().ConstantValue() == l_max); \
+ EXPECT(right_range->min().ConstantValue() == r_min); \
+ EXPECT(right_range->max().ConstantValue() == r_max); \
+ Range::Sub(left_range, right_range, &min, &max, NULL); \
+ EXPECT(min.Equals(result_min)); \
+ if (!min.Equals(result_min)) { \
+ OS::Print("%s != %s\n", min.ToCString(), result_min.ToCString()); \
+ } \
+ EXPECT(max.Equals(result_max)); \
+ if (!max.Equals(result_max)) { \
+ OS::Print("%s != %s\n", max.ToCString(), result_max.ToCString()); \
+ } \
+ }
+
+ // [kMaxInt32, kMaxInt32 + 15] - [10, 20] = [kMaxInt32 - 20, kMaxInt32 + 5].
+ TEST_RANGE_SUB(static_cast<int64_t>(kMaxInt32),
+ static_cast<int64_t>(kMaxInt32) + 15,
+ static_cast<int64_t>(10),
+ static_cast<int64_t>(20),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) - 20),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) + 5));
+
+ // [kMintInt64, kMintInt64] - [1, 1] = [-inf, +inf].
+ TEST_RANGE_SUB(static_cast<int64_t>(kMinInt64),
+ static_cast<int64_t>(kMinInt64),
+ static_cast<int64_t>(1),
+ static_cast<int64_t>(1),
+ RangeBoundary::NegativeInfinity(),
+ RangeBoundary::PositiveInfinity());
+
+ // [1, 1] - [kMintInt64, kMintInt64] = [-inf, +inf].
+ TEST_RANGE_SUB(static_cast<int64_t>(1),
+ static_cast<int64_t>(1),
+ static_cast<int64_t>(kMinInt64),
+ static_cast<int64_t>(kMinInt64),
+ RangeBoundary::NegativeInfinity(),
+ RangeBoundary::PositiveInfinity());
+
+ // [kMaxInt32 + 10, kMaxInt32 + 20] - [-20, -20] =
+ // [kMaxInt32 + 30, kMaxInt32 + 40].
+ TEST_RANGE_SUB(static_cast<int64_t>(kMaxInt32) + 10,
+ static_cast<int64_t>(kMaxInt32) + 20,
+ static_cast<int64_t>(-20),
+ static_cast<int64_t>(-20),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) + 30),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32) + 40));
+
+
+#undef TEST_RANGE_SUB
+}
+
+
+TEST_CASE(RangeAnd) {
+#define TEST_RANGE_AND(l_min, l_max, r_min, r_max, result_min, result_max) \
+ { \
+ RangeBoundary min, max; \
+ Range* left_range = new Range( \
+ RangeBoundary::FromConstant(l_min), \
+ RangeBoundary::FromConstant(l_max)); \
+ Range* right_range = new Range( \
+ RangeBoundary::FromConstant(r_min), \
+ RangeBoundary::FromConstant(r_max)); \
+ EXPECT(left_range->min().ConstantValue() == l_min); \
+ EXPECT(left_range->max().ConstantValue() == l_max); \
+ EXPECT(right_range->min().ConstantValue() == r_min); \
+ EXPECT(right_range->max().ConstantValue() == r_max); \
+ Range::And(left_range, right_range, &min, &max); \
+ EXPECT(min.Equals(result_min)); \
+ if (!min.Equals(result_min)) { \
+ OS::Print("%s != %s\n", min.ToCString(), result_min.ToCString()); \
+ } \
+ EXPECT(max.Equals(result_max)); \
+ if (!max.Equals(result_max)) { \
+ OS::Print("%s != %s\n", max.ToCString(), result_max.ToCString()); \
+ } \
+ }
+
+ // [0xff, 0xfff] & [0xf, 0xf] = [0x0, 0xf].
+ TEST_RANGE_AND(static_cast<int64_t>(0xff),
+ static_cast<int64_t>(0xfff),
+ static_cast<int64_t>(0xf),
+ static_cast<int64_t>(0xf),
+ RangeBoundary(0),
+ RangeBoundary(0xf));
+
+ // [0xffffffff, 0xffffffff] & [0xfffffffff, 0xfffffffff] = [0x0, 0xfffffffff].
+ TEST_RANGE_AND(static_cast<int64_t>(0xffffffff),
+ static_cast<int64_t>(0xffffffff),
+ static_cast<int64_t>(0xfffffffff),
+ static_cast<int64_t>(0xfffffffff),
+ RangeBoundary(0),
+ RangeBoundary(static_cast<int64_t>(0xfffffffff)));
+
+ // [0xffffffff, 0xffffffff] & [-20, 20] = [0x0, 0xffffffff].
+ TEST_RANGE_AND(static_cast<int64_t>(0xffffffff),
+ static_cast<int64_t>(0xffffffff),
+ static_cast<int64_t>(-20),
+ static_cast<int64_t>(20),
+ RangeBoundary(0),
+ RangeBoundary(static_cast<int64_t>(0xffffffff)));
+
+ // [-20, 20] & [0xffffffff, 0xffffffff] = [0x0, 0xffffffff].
+ TEST_RANGE_AND(static_cast<int64_t>(-20),
+ static_cast<int64_t>(20),
+ static_cast<int64_t>(0xffffffff),
+ static_cast<int64_t>(0xffffffff),
+ RangeBoundary(0),
+ RangeBoundary(static_cast<int64_t>(0xffffffff)));
+
+ // Test that [-20, 20] & [-20, 20] = [Unknown, Unknown].
+ TEST_RANGE_AND(static_cast<int64_t>(-20),
+ static_cast<int64_t>(20),
+ static_cast<int64_t>(-20),
+ static_cast<int64_t>(20),
+ RangeBoundary(),
+ RangeBoundary());
+
+#undef TEST_RANGE_AND
+}
+
+
+TEST_CASE(RangeMinMax) {
+ // Constants.
+ // MIN(0, 1) == 0
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
+ // MIN(0, -1) == -1
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
+
+ // MIN(1, 0) == 0
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
+ // MIN(-1, 0) == -1
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
+
+ // MAX(0, 1) == 1
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
+
+ // MAX(0, -1) == 0
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
+
+ // MAX(1, 0) == 1
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
+ // MAX(-1, 0) == 0
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
+
+ RangeBoundary n_infinity = RangeBoundary::NegativeInfinity();
+ RangeBoundary p_infinity = RangeBoundary::PositiveInfinity();
+
+ // Constants vs. infinity.
+ EXPECT(RangeBoundary::Max(
+ n_infinity,
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
+
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary::FromConstant(-1),
+ n_infinity,
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
+
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary::FromConstant(1),
+ n_infinity,
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
+
+ EXPECT(RangeBoundary::Max(
+ n_infinity,
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
+
+ EXPECT(RangeBoundary::Min(
+ p_infinity,
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
+
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary::FromConstant(-1),
+ p_infinity,
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
+
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary::FromConstant(1),
+ p_infinity,
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
+
+ EXPECT(RangeBoundary::Min(
+ p_infinity,
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
+
+ // 64-bit values.
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary(static_cast<int64_t>(kMinInt64)),
+ RangeBoundary(static_cast<int64_t>(kMinInt32)),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMinInt64);
+
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary(static_cast<int64_t>(kMinInt64)),
+ RangeBoundary(static_cast<int64_t>(kMinInt32)),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMinInt32);
+
+ EXPECT(RangeBoundary::Min(
+ RangeBoundary(static_cast<int64_t>(kMaxInt64)),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32)),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMaxInt32);
+
+ EXPECT(RangeBoundary::Max(
+ RangeBoundary(static_cast<int64_t>(kMaxInt64)),
+ RangeBoundary(static_cast<int64_t>(kMaxInt32)),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == kMaxInt64);
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698