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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 333643004: Add range analysis for left-shift smi operations. (Closed) Base URL: http://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
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 37229)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -3112,6 +3112,10 @@
}
return;
}
+ case Token::kSHL: {
+ Range::Shl(left_range, right_range, &min, &max);
+ break;
+ }
case Token::kBIT_AND:
if (Range::ConstantMin(right_range).value() >= 0) {
min = RangeBoundary::FromConstant(0);
@@ -3236,6 +3240,35 @@
}
+void Range::Shl(Range* left,
+ Range* right,
+ RangeBoundary* result_min,
+ RangeBoundary* result_max) {
+ RangeBoundary left_max = Range::ConstantMax(left);
+ RangeBoundary left_min = Range::ConstantMin(left);
+ // Ignore negative values of shift count because shift by a negative shift
+ // count does give a result.
+ intptr_t right_max = Range::ConstantMax(right).value() > 0
Vyacheslav Egorov (Google) 2014/06/12 14:59:00 Can be written as Max(Range::ConstantMax(right).va
Florian Schneider 2014/06/12 15:12:42 Done.
+ ? Range::ConstantMax(right).value() : 0;
+ intptr_t right_min = Range::ConstantMin(right).value() > 0
Vyacheslav Egorov (Google) 2014/06/12 14:59:00 ditto
Florian Schneider 2014/06/12 15:12:42 Done.
+ ? Range::ConstantMin(right).value() : 0;
+
+ *result_min = RangeBoundary::Shl(
+ left_min,
+ left_min.value() > 0 ? right_min : right_max,
+ left_min.value() > 0
+ ? RangeBoundary::PositiveInfinity()
+ : RangeBoundary::NegativeInfinity());
+
+ *result_max = RangeBoundary::Shl(
+ left_max,
+ left_max.value() > 0 ? right_max : right_min,
+ left_max.value() > 0
+ ? RangeBoundary::PositiveInfinity()
+ : RangeBoundary::NegativeInfinity());
+}
+
+
bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) {
return LoadFieldInstr::IsFixedLengthArrayCid(cid);
}

Powered by Google App Engine
This is Rietveld 408576698