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

Unified Diff: runtime/vm/constant_propagator.cc

Issue 2955073005: VM-codegen: Add IL instruction to check if a Smi is in a constant range
Patch Set: Remove unrelated change and other Slava feedback Created 3 years, 5 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 | « no previous file | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/constant_propagator.cc
diff --git a/runtime/vm/constant_propagator.cc b/runtime/vm/constant_propagator.cc
index dec674c2c1171f78b4ea6b7407af9d611738bdf8..f3dd267d1c8443cabae9771b8d902c3ef4f61080 100644
--- a/runtime/vm/constant_propagator.cc
+++ b/runtime/vm/constant_propagator.cc
@@ -431,6 +431,22 @@ void ConstantPropagator::VisitIfThenElse(IfThenElseInstr* instr) {
}
+void ConstantPropagator::VisitSmiRangeComparison(
+ SmiRangeComparisonInstr* instr) {
+ Definition* defn = instr->input()->definition();
+ const Object& value = defn->constant_value();
+ if (IsConstant(value)) {
+ ASSERT(value.IsSmi());
+ intptr_t number = Smi::Cast(value).Value();
+ bool result = instr->to() <= number && number <= instr->from();
+ if (instr->is_negated()) result = !result;
+ SetValue(instr, Bool::Get(result));
+ } else if (IsNonConstant(value)) {
+ SetValue(instr, non_constant_);
+ }
+}
+
+
void ConstantPropagator::VisitStrictCompare(StrictCompareInstr* instr) {
Definition* left_defn = instr->left()->definition();
Definition* right_defn = instr->right()->definition();
« no previous file with comments | « no previous file | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698