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

Unified Diff: runtime/vm/flow_graph_optimizer.cc

Issue 59613005: Merge (x & y) == 0 pattern to emit a single test instruction. (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
Index: runtime/vm/flow_graph_optimizer.cc
===================================================================
--- runtime/vm/flow_graph_optimizer.cc (revision 29964)
+++ runtime/vm/flow_graph_optimizer.cc (working copy)
@@ -6336,6 +6336,26 @@
}
+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();

Powered by Google App Engine
This is Rietveld 408576698