Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/branch-elimination.h" | 5 #include "src/compiler/branch-elimination.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
| 9 #include "src/compiler/simplified-operator.h" | 9 #include "src/compiler/simplified-operator.h" |
| 10 | 10 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 // Here we rely on having only reducible loops: | 138 // Here we rely on having only reducible loops: |
| 139 // The loop entry edge always dominates the header, so we can just use | 139 // The loop entry edge always dominates the header, so we can just use |
| 140 // the information from the loop entry edge. | 140 // the information from the loop entry edge. |
| 141 return TakeConditionsFromFirstControl(node); | 141 return TakeConditionsFromFirstControl(node); |
| 142 } | 142 } |
| 143 | 143 |
| 144 | 144 |
| 145 Reduction BranchElimination::ReduceMerge(Node* node) { | 145 Reduction BranchElimination::ReduceMerge(Node* node) { |
| 146 // Shortcut for the case when we do not know anything about some | 146 // Shortcut for the case when we do not know anything about some |
| 147 // input. | 147 // input. |
| 148 for (Node* input : node->inputs()) { | 148 Node::Inputs inputs = node->inputs(); |
| 149 for (Node* input : inputs) { | |
| 149 if (node_conditions_.Get(input) == nullptr) { | 150 if (node_conditions_.Get(input) == nullptr) { |
| 150 return UpdateConditions(node, nullptr); | 151 return UpdateConditions(node, nullptr); |
| 151 } | 152 } |
| 152 } | 153 } |
| 153 | 154 |
| 154 const ControlPathConditions* first = node_conditions_.Get(node->InputAt(0)); | 155 auto input_it = inputs.begin(); |
| 156 | |
| 157 DCHECK_GT(inputs.count(), 0); | |
| 158 | |
| 159 const ControlPathConditions* first = node_conditions_.Get(*input_it); | |
| 160 ++input_it; | |
| 155 // Make a copy of the first input's conditions and merge with the conditions | 161 // Make a copy of the first input's conditions and merge with the conditions |
| 156 // from other inputs. | 162 // from other inputs. |
| 157 ControlPathConditions* conditions = | 163 ControlPathConditions* conditions = |
| 158 new (zone_->New(sizeof(ControlPathConditions))) | 164 new (zone_->New(sizeof(ControlPathConditions))) |
| 159 ControlPathConditions(*first); | 165 ControlPathConditions(*first); |
| 160 for (int i = 1; i < node->InputCount(); i++) { | 166 auto input_end = inputs.end(); |
| 161 conditions->Merge(*(node_conditions_.Get(node->InputAt(i)))); | 167 for (; input_it != input_end; ++input_it) { |
| 168 conditions->Merge(*(node_conditions_.Get(*input_it))); | |
|
Jarin
2017/01/10 10:53:38
Again, this is longer and harder to read.
Leszek Swirski
2017/01/10 12:03:38
This one I'd rather keep, merges can have a lot of
| |
| 162 } | 169 } |
| 163 | 170 |
| 164 return UpdateConditions(node, conditions); | 171 return UpdateConditions(node, conditions); |
| 165 } | 172 } |
| 166 | 173 |
| 167 | 174 |
| 168 Reduction BranchElimination::ReduceStart(Node* node) { | 175 Reduction BranchElimination::ReduceStart(Node* node) { |
| 169 return UpdateConditions(node, ControlPathConditions::Empty(zone_)); | 176 return UpdateConditions(node, ControlPathConditions::Empty(zone_)); |
| 170 } | 177 } |
| 171 | 178 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 | 313 |
| 307 Graph* BranchElimination::graph() const { return jsgraph()->graph(); } | 314 Graph* BranchElimination::graph() const { return jsgraph()->graph(); } |
| 308 | 315 |
| 309 CommonOperatorBuilder* BranchElimination::common() const { | 316 CommonOperatorBuilder* BranchElimination::common() const { |
| 310 return jsgraph()->common(); | 317 return jsgraph()->common(); |
| 311 } | 318 } |
| 312 | 319 |
| 313 } // namespace compiler | 320 } // namespace compiler |
| 314 } // namespace internal | 321 } // namespace internal |
| 315 } // namespace v8 | 322 } // namespace v8 |
| OLD | NEW |