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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 81623003: Use range information to omit checks in TRUNCDIV/MOD operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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_arm.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 30671)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -1114,6 +1114,10 @@
}
return true;
}
+ case Token::kMOD: {
+ Range* right_range = this->right()->definition()->range();
+ return (right_range == NULL) || right_range->Overlaps(0, 0);
+ }
default:
return overflow_;
}
@@ -2686,6 +2690,16 @@
}
+bool Range::Overlaps(intptr_t min_int, intptr_t max_int) const {
+ const intptr_t this_min = min().LowerBound().value();
+ const intptr_t this_max = max().UpperBound().value();
+ if ((this_min <= min_int) && (min_int <= this_max)) return true;
+ if ((this_min <= max_int) && (max_int <= this_max)) return true;
+ if ((min_int < this_min) && (max_int > this_max)) return true;
+ return false;
+}
+
+
bool Range::IsUnsatisfiable() const {
// Constant case: For example [0, -1].
if (Range::ConstantMin(this).value() > Range::ConstantMax(this).value()) {
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/intermediate_language_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698