| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/branch_optimizer.h" | 5 #include "vm/branch_optimizer.h" |
| 6 | 6 |
| 7 #include "vm/flow_graph.h" | 7 #include "vm/flow_graph.h" |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 | 77 |
| 78 BranchInstr* BranchSimplifier::CloneBranch(Zone* zone, | 78 BranchInstr* BranchSimplifier::CloneBranch(Zone* zone, |
| 79 BranchInstr* branch, | 79 BranchInstr* branch, |
| 80 Value* new_left, | 80 Value* new_left, |
| 81 Value* new_right) { | 81 Value* new_right) { |
| 82 ComparisonInstr* comparison = branch->comparison(); | 82 ComparisonInstr* comparison = branch->comparison(); |
| 83 ComparisonInstr* new_comparison = | 83 ComparisonInstr* new_comparison = |
| 84 comparison->CopyWithNewOperands(new_left, new_right); | 84 comparison->CopyWithNewOperands(new_left, new_right); |
| 85 BranchInstr* new_branch = new (zone) BranchInstr(new_comparison); | 85 BranchInstr* new_branch = new (zone) BranchInstr(new_comparison); |
| 86 new_branch->set_is_checked(branch->is_checked()); | |
| 87 return new_branch; | 86 return new_branch; |
| 88 } | 87 } |
| 89 | 88 |
| 90 | 89 |
| 91 void BranchSimplifier::Simplify(FlowGraph* flow_graph) { | 90 void BranchSimplifier::Simplify(FlowGraph* flow_graph) { |
| 92 // Optimize some branches that test the value of a phi. When it is safe | 91 // Optimize some branches that test the value of a phi. When it is safe |
| 93 // to do so, push the branch to each of the predecessor blocks. This is | 92 // to do so, push the branch to each of the predecessor blocks. This is |
| 94 // an optimization when (a) it can avoid materializing a boolean object at | 93 // an optimization when (a) it can avoid materializing a boolean object at |
| 95 // the phi only to test its value, and (b) it can expose opportunities for | 94 // the phi only to test its value, and (b) it can expose opportunities for |
| 96 // constant propagation and unreachable code elimination. This | 95 // constant propagation and unreachable code elimination. This |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 if (changed) { | 335 if (changed) { |
| 337 // We may have changed the block order and the dominator tree. | 336 // We may have changed the block order and the dominator tree. |
| 338 flow_graph->DiscoverBlocks(); | 337 flow_graph->DiscoverBlocks(); |
| 339 GrowableArray<BitVector*> dominance_frontier; | 338 GrowableArray<BitVector*> dominance_frontier; |
| 340 flow_graph->ComputeDominators(&dominance_frontier); | 339 flow_graph->ComputeDominators(&dominance_frontier); |
| 341 } | 340 } |
| 342 } | 341 } |
| 343 | 342 |
| 344 | 343 |
| 345 } // namespace dart | 344 } // namespace dart |
| OLD | NEW |