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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 6318 matching lines...) Expand 10 before | Expand all | Expand 10 after
6329 case Token::kGT: return (result > 0); 6329 case Token::kGT: return (result > 0);
6330 case Token::kLTE: return (result <= 0); 6330 case Token::kLTE: return (result <= 0);
6331 case Token::kGTE: return (result >= 0); 6331 case Token::kGTE: return (result >= 0);
6332 default: 6332 default:
6333 UNREACHABLE(); 6333 UNREACHABLE();
6334 return false; 6334 return false;
6335 } 6335 }
6336 } 6336 }
6337 6337
6338 6338
6339 void ConstantPropagator::VisitTestSmi(TestSmiInstr* instr) {
6340 const Object& left = instr->left()->definition()->constant_value();
6341 const Object& right = instr->right()->definition()->constant_value();
6342 if (IsNonConstant(left) || IsNonConstant(right)) {
6343 SetValue(instr, non_constant_);
6344 } else if (IsConstant(left) && IsConstant(right)) {
6345 if (left.IsInteger() && right.IsInteger()) {
6346 const bool result = CompareIntegers(
6347 instr->kind(),
6348 Integer::Handle(Integer::Cast(left).BitOp(Token::kBIT_AND,
6349 Integer::Cast(right))),
6350 Smi::Handle(Smi::New(0)));
6351 SetValue(instr, result ? Bool::True() : Bool::False());
6352 } else {
6353 SetValue(instr, non_constant_);
6354 }
6355 }
6356 }
6357
6358
6339 void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) { 6359 void ConstantPropagator::VisitEqualityCompare(EqualityCompareInstr* instr) {
6340 const Object& left = instr->left()->definition()->constant_value(); 6360 const Object& left = instr->left()->definition()->constant_value();
6341 const Object& right = instr->right()->definition()->constant_value(); 6361 const Object& right = instr->right()->definition()->constant_value();
6342 6362
6343 if (instr->left()->definition() == instr->right()->definition()) { 6363 if (instr->left()->definition() == instr->right()->definition()) {
6344 // Fold x == x, and x != x to true/false for numbers comparisons. 6364 // Fold x == x, and x != x to true/false for numbers comparisons.
6345 if (RawObject::IsIntegerClassId(instr->operation_cid())) { 6365 if (RawObject::IsIntegerClassId(instr->operation_cid())) {
6346 return SetValue(instr, Bool::Get(instr->kind() == Token::kEQ)); 6366 return SetValue(instr, Bool::Get(instr->kind() == Token::kEQ));
6347 } 6367 }
6348 } 6368 }
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
7847 } 7867 }
7848 7868
7849 // Insert materializations at environment uses. 7869 // Insert materializations at environment uses.
7850 for (intptr_t i = 0; i < exits.length(); i++) { 7870 for (intptr_t i = 0; i < exits.length(); i++) {
7851 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7871 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7852 } 7872 }
7853 } 7873 }
7854 7874
7855 7875
7856 } // namespace dart 7876 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698