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

Unified Diff: runtime/vm/flow_graph_range_analysis_test.cc

Issue 472303002: Revert "Switch to a fix-point based range analysis to improve its precision." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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/flow_graph_range_analysis.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_range_analysis_test.cc
diff --git a/runtime/vm/flow_graph_range_analysis_test.cc b/runtime/vm/flow_graph_range_analysis_test.cc
index 57040d673187555247092cfe82b6fe9c86c43208..0471748860663b637f5f621c33b52959d0ec2633 100644
--- a/runtime/vm/flow_graph_range_analysis_test.cc
+++ b/runtime/vm/flow_graph_range_analysis_test.cc
@@ -261,53 +261,40 @@ TEST_CASE(RangeBinaryOp) {
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,
- &result);
- ASSERT(!Range::IsUnknown(&result));
- EXPECT(result.min().IsNegativeInfinity());
- EXPECT(result.max().IsPositiveInfinity());
- }
+ 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);
- {
- Range result;
- Range::BinaryOp(Token::kADD,
- range_c,
- range_d,
- NULL,
- &result);
- ASSERT(!Range::IsUnknown(&result));
- 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));
- {
- Range result;
- Range::BinaryOp(Token::kBIT_AND,
- range_e,
- range_f,
- NULL,
- &result);
- ASSERT(!Range::IsUnknown(&result));
- EXPECT(result.min().ConstantValue() == 0x0);
- EXPECT(result.max().ConstantValue() == 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);
}
@@ -538,151 +525,118 @@ TEST_CASE(RangeAnd) {
}
-TEST_CASE(RangeIntersectionMinMax) {
- // Test IntersectionMin and IntersectionMax methods which for constants are
- // simply defined as Max/Min respectively.
-
+TEST_CASE(RangeMinMax) {
// Constants.
// MIN(0, 1) == 0
- EXPECT(RangeBoundary::IntersectionMax(
+ EXPECT(RangeBoundary::Min(
RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(1)).ConstantValue() == 0);
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
// MIN(0, -1) == -1
- EXPECT(RangeBoundary::IntersectionMax(
+ EXPECT(RangeBoundary::Min(
RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(-1)).ConstantValue() == -1);
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
// MIN(1, 0) == 0
- EXPECT(RangeBoundary::IntersectionMax(
+ EXPECT(RangeBoundary::Min(
RangeBoundary::FromConstant(1),
- RangeBoundary::FromConstant(0)).ConstantValue() == 0);
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
// MIN(-1, 0) == -1
- EXPECT(RangeBoundary::IntersectionMax(
+ EXPECT(RangeBoundary::Min(
RangeBoundary::FromConstant(-1),
- RangeBoundary::FromConstant(0)).ConstantValue() == -1);
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
// MAX(0, 1) == 1
- EXPECT(RangeBoundary::IntersectionMin(
+ EXPECT(RangeBoundary::Max(
RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(1)).ConstantValue() == 1);
+ RangeBoundary::FromConstant(1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
// MAX(0, -1) == 0
- EXPECT(RangeBoundary::IntersectionMin(
+ EXPECT(RangeBoundary::Max(
RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(-1)).ConstantValue() == 0);
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
// MAX(1, 0) == 1
- EXPECT(RangeBoundary::IntersectionMin(
+ EXPECT(RangeBoundary::Max(
RangeBoundary::FromConstant(1),
- RangeBoundary::FromConstant(0)).ConstantValue() == 1);
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
// MAX(-1, 0) == 0
- EXPECT(RangeBoundary::IntersectionMin(
+ EXPECT(RangeBoundary::Max(
RangeBoundary::FromConstant(-1),
- RangeBoundary::FromConstant(0)).ConstantValue() == 0);
+ RangeBoundary::FromConstant(0),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 0);
RangeBoundary n_infinity = RangeBoundary::NegativeInfinity();
RangeBoundary p_infinity = RangeBoundary::PositiveInfinity();
// Constants vs. infinity.
- EXPECT(RangeBoundary::IntersectionMin(
+ EXPECT(RangeBoundary::Max(
n_infinity,
- RangeBoundary::FromConstant(-1)).ConstantValue() == -1);
+ RangeBoundary::FromConstant(-1),
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
- EXPECT(RangeBoundary::IntersectionMin(
+ EXPECT(RangeBoundary::Max(
RangeBoundary::FromConstant(-1),
- n_infinity).ConstantValue() == -1);
+ n_infinity,
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
- EXPECT(RangeBoundary::IntersectionMin(
+ EXPECT(RangeBoundary::Max(
RangeBoundary::FromConstant(1),
- n_infinity).ConstantValue() == 1);
-
- EXPECT(RangeBoundary::IntersectionMin(
n_infinity,
- RangeBoundary::FromConstant(1)).ConstantValue() == 1);
-
- EXPECT(RangeBoundary::IntersectionMax(
- p_infinity,
- RangeBoundary::FromConstant(-1)).ConstantValue() == -1);
-
- EXPECT(RangeBoundary::IntersectionMax(
- RangeBoundary::FromConstant(-1),
- p_infinity).ConstantValue() == -1);
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
- EXPECT(RangeBoundary::IntersectionMax(
+ EXPECT(RangeBoundary::Max(
+ n_infinity,
RangeBoundary::FromConstant(1),
- p_infinity).ConstantValue() == 1);
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
- EXPECT(RangeBoundary::IntersectionMax(
+ EXPECT(RangeBoundary::Min(
p_infinity,
- RangeBoundary::FromConstant(1)).ConstantValue() == 1);
-}
-
-
-TEST_CASE(RangeJoinMinMax) {
- // Test IntersectionMin and IntersectionMax methods which for constants are
- // simply defined as Min/Max respectively.
-
- // Constants.
- EXPECT(RangeBoundary::JoinMax(
- RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(1)).ConstantValue() == 1);
- EXPECT(RangeBoundary::JoinMax(
- RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(-1)).ConstantValue() == 0);
- EXPECT(RangeBoundary::JoinMax(
- RangeBoundary::FromConstant(1),
- RangeBoundary::FromConstant(0)).ConstantValue() == 1);
- EXPECT(RangeBoundary::JoinMax(
- RangeBoundary::FromConstant(-1),
- RangeBoundary::FromConstant(0)).ConstantValue() == 0);
- EXPECT(RangeBoundary::JoinMin(
- RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(1)).ConstantValue() == 0);
- EXPECT(RangeBoundary::JoinMin(
- RangeBoundary::FromConstant(0),
- RangeBoundary::FromConstant(-1)).ConstantValue() == -1);
- EXPECT(RangeBoundary::JoinMin(
- RangeBoundary::FromConstant(1),
- RangeBoundary::FromConstant(0)).ConstantValue() == 0);
- EXPECT(RangeBoundary::JoinMin(
RangeBoundary::FromConstant(-1),
- RangeBoundary::FromConstant(0)).ConstantValue() == -1);
-
- RangeBoundary n_infinity = RangeBoundary::NegativeInfinity();
- RangeBoundary p_infinity = RangeBoundary::PositiveInfinity();
-
- // Constants vs. infinity.
- EXPECT(RangeBoundary::JoinMin(
- n_infinity,
- RangeBoundary::FromConstant(-1)).IsSmiMinimumOrBelow());
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
- EXPECT(RangeBoundary::JoinMin(
+ EXPECT(RangeBoundary::Min(
RangeBoundary::FromConstant(-1),
- n_infinity).IsSmiMinimumOrBelow());
-
- EXPECT(RangeBoundary::JoinMin(
- RangeBoundary::FromConstant(1),
- n_infinity).IsSmiMinimumOrBelow());
-
- EXPECT(RangeBoundary::JoinMin(
- n_infinity,
- RangeBoundary::FromConstant(1)).IsSmiMinimumOrBelow());
-
- EXPECT(RangeBoundary::JoinMax(
p_infinity,
- RangeBoundary::FromConstant(-1)).IsSmiMaximumOrAbove());
-
- EXPECT(RangeBoundary::JoinMax(
- RangeBoundary::FromConstant(-1),
- p_infinity).IsSmiMaximumOrAbove());
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == -1);
- EXPECT(RangeBoundary::JoinMax(
+ EXPECT(RangeBoundary::Min(
RangeBoundary::FromConstant(1),
- p_infinity).IsSmiMaximumOrAbove());
+ p_infinity,
+ RangeBoundary::kRangeBoundaryInt64).ConstantValue() == 1);
- EXPECT(RangeBoundary::JoinMax(
+ EXPECT(RangeBoundary::Min(
p_infinity,
- RangeBoundary::FromConstant(1)).IsSmiMaximumOrAbove());
+ 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/flow_graph_range_analysis.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698