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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 11175013: Add range to kBIT_AND with positive constants. Use that range to eliminate compares in left shifts. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 14103)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -2187,26 +2187,43 @@
switch (op_kind()) {
case Token::kADD:
new_min =
- RangeBoundary::Add(Range::ConstantMin(left_range),
- Range::ConstantMin(right_range),
- RangeBoundary::OverflowedMinSmi());
+ RangeBoundary::Add(Range::ConstantMin(left_range),
+ Range::ConstantMin(right_range),
+ RangeBoundary::OverflowedMinSmi());
new_max =
- RangeBoundary::Add(Range::ConstantMax(left_range),
- Range::ConstantMax(right_range),
- RangeBoundary::OverflowedMaxSmi());
+ RangeBoundary::Add(Range::ConstantMax(left_range),
+ Range::ConstantMax(right_range),
+ RangeBoundary::OverflowedMaxSmi());
break;
case Token::kSUB:
new_min =
- RangeBoundary::Sub(Range::ConstantMin(left_range),
- Range::ConstantMax(right_range),
- RangeBoundary::OverflowedMinSmi());
+ RangeBoundary::Sub(Range::ConstantMin(left_range),
+ Range::ConstantMax(right_range),
+ RangeBoundary::OverflowedMinSmi());
new_max =
- RangeBoundary::Sub(Range::ConstantMax(left_range),
- Range::ConstantMin(right_range),
- RangeBoundary::OverflowedMaxSmi());
+ RangeBoundary::Sub(Range::ConstantMax(left_range),
+ Range::ConstantMin(right_range),
+ RangeBoundary::OverflowedMaxSmi());
break;
+ case Token::kBIT_AND:
+ if (Range::ConstantMin(right_range).value() >= 0) {
+ new_min = RangeBoundary::FromConstant(0);
+ new_max = Range::ConstantMax(right_range);
+ break;
+ }
+ if (Range::ConstantMin(left_range).value() >= 0) {
+ new_min = RangeBoundary::FromConstant(0);
+ new_max = Range::ConstantMax(left_range);
+ break;
+ }
+
+ if (range_ == NULL) {
+ range_ = Range::Unknown();
+ }
+ return;
+
default:
if (range_ == NULL) {
range_ = Range::Unknown();
@@ -2221,6 +2238,14 @@
}
+// Inclusive.
+bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const {
+ if (!min().IsConstant() || (min().value() < min_int)) return false;
Vyacheslav Egorov (Google) 2012/10/26 12:21:42 I suggest using LowerBound() and UpperBound() here
srdjan 2012/10/30 18:21:13 Done.
+ if (!max().IsConstant() || (max().value() > max_int)) return false;
+ return true;
+}
+
+
#undef __
} // namespace dart
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698