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 26 matching lines...) Expand all Loading... | |
37 // | 37 // |
38 // Branch(Comparison(kind, Phi, Constant)) | 38 // Branch(Comparison(kind, Phi, Constant)) |
39 // | 39 // |
40 // These are the branches produced by inlining in a test context. Also, | 40 // These are the branches produced by inlining in a test context. Also, |
41 // the phi has no other uses so they can simply be eliminated. The block | 41 // the phi has no other uses so they can simply be eliminated. The block |
42 // has no other phis and no instructions intervening between the phi and | 42 // has no other phis and no instructions intervening between the phi and |
43 // branch so the block can simply be eliminated. | 43 // branch so the block can simply be eliminated. |
44 BranchInstr* branch = block->last_instruction()->AsBranch(); | 44 BranchInstr* branch = block->last_instruction()->AsBranch(); |
45 ASSERT(branch != NULL); | 45 ASSERT(branch != NULL); |
46 ComparisonInstr* comparison = branch->comparison(); | 46 ComparisonInstr* comparison = branch->comparison(); |
47 if (comparison->InputCount() != 2) return false; | |
zra
2016/10/31 17:28:14
Please use {}
Florian Schneider
2016/10/31 18:48:16
Done.
| |
47 Value* left = comparison->left(); | 48 Value* left = comparison->left(); |
48 PhiInstr* phi = left->definition()->AsPhi(); | 49 PhiInstr* phi = left->definition()->AsPhi(); |
49 Value* right = comparison->right(); | 50 Value* right = comparison->right(); |
50 ConstantInstr* constant = | 51 ConstantInstr* constant = |
51 (right == NULL) ? NULL : right->definition()->AsConstant(); | 52 (right == NULL) ? NULL : right->definition()->AsConstant(); |
52 return (phi != NULL) && | 53 return (phi != NULL) && |
53 (constant != NULL) && | 54 (constant != NULL) && |
54 (phi->GetBlock() == block) && | 55 (phi->GetBlock() == block) && |
55 PhiHasSingleUse(phi, left) && | 56 PhiHasSingleUse(phi, left) && |
56 (block->next() == branch) && | 57 (block->next() == branch) && |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 if (changed) { | 347 if (changed) { |
347 // We may have changed the block order and the dominator tree. | 348 // We may have changed the block order and the dominator tree. |
348 flow_graph->DiscoverBlocks(); | 349 flow_graph->DiscoverBlocks(); |
349 GrowableArray<BitVector*> dominance_frontier; | 350 GrowableArray<BitVector*> dominance_frontier; |
350 flow_graph->ComputeDominators(&dominance_frontier); | 351 flow_graph->ComputeDominators(&dominance_frontier); |
351 } | 352 } |
352 } | 353 } |
353 | 354 |
354 | 355 |
355 } // namespace dart | 356 } // namespace dart |
OLD | NEW |