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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 14251023: Merge (x & y) == 0 pattern to emit a single test instruction. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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/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_optimizer.cc
diff --git a/runtime/vm/flow_graph_optimizer.cc b/runtime/vm/flow_graph_optimizer.cc
index 8833ac305ece4a6b6142de01cbd087c395f6006d..4f8e4a6ea5b617180c94b016ec628cb5075b2a4c 100644
--- a/runtime/vm/flow_graph_optimizer.cc
+++ b/runtime/vm/flow_graph_optimizer.cc
@@ -4049,6 +4049,26 @@ static bool CompareIntegers(Token::Kind kind,
}
+void ConstantPropagator::VisitTestSmi(TestSmiInstr* instr) {
+ const Object& left = instr->left()->definition()->constant_value();
+ const Object& right = instr->right()->definition()->constant_value();
+ if (IsNonConstant(left) || IsNonConstant(right)) {
+ SetValue(instr, non_constant_);
+ } else if (IsConstant(left) && IsConstant(right)) {
+ if (left.IsInteger() && right.IsInteger()) {
+ const bool result = CompareIntegers(
+ instr->kind(),
+ Integer::Handle(Integer::Cast(left).BitOp(Token::kBIT_AND,
+ Integer::Cast(right))),
+ Smi::Handle(Smi::New(0)));
+ SetValue(instr, result ? Bool::True() : Bool::False());
+ } else {
+ SetValue(instr, non_constant_);
+ }
+ }
+}
+
+
void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) {
const Object& left = instr->left()->definition()->constant_value();
const Object& right = instr->right()->definition()->constant_value();
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698