| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/select-lowering.h" | 5 #include "src/compiler/select-lowering.h" |
| 6 | 6 |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/diamond.h" | 8 #include "src/compiler/diamond.h" |
| 9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
| 10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 Reduction SelectLowering::Reduce(Node* node) { | 25 Reduction SelectLowering::Reduce(Node* node) { |
| 26 if (node->opcode() != IrOpcode::kSelect) return NoChange(); | 26 if (node->opcode() != IrOpcode::kSelect) return NoChange(); |
| 27 SelectParameters const p = SelectParametersOf(node->op()); | 27 SelectParameters const p = SelectParametersOf(node->op()); |
| 28 | 28 |
| 29 Node* const cond = node->InputAt(0); | 29 Node* const cond = node->InputAt(0); |
| 30 | 30 |
| 31 // Check if we already have a diamond for this condition. | 31 // Check if we already have a diamond for this condition. |
| 32 auto i = merges_.find(cond); | 32 auto i = merges_.find(cond); |
| 33 if (i == merges_.end()) { | 33 if (i == merges_.end()) { |
| 34 // Create a new diamond for this condition and remember its merge node. | 34 // Create a new diamond for this condition and remember its merge node. |
| 35 Diamond d(graph(), common(), cond); | 35 Diamond d(graph(), common(), cond, p.hint()); |
| 36 i = merges_.insert(std::make_pair(cond, d.merge)).first; | 36 i = merges_.insert(std::make_pair(cond, d.merge)).first; |
| 37 } | 37 } |
| 38 | 38 |
| 39 DCHECK_EQ(cond, i->first); | 39 DCHECK_EQ(cond, i->first); |
| 40 | 40 |
| 41 // Create a Phi hanging off the previously determined merge. | 41 // Create a Phi hanging off the previously determined merge. |
| 42 node->set_op(common()->Phi(p.type(), 2)); | 42 node->set_op(common()->Phi(p.type(), 2)); |
| 43 node->ReplaceInput(0, node->InputAt(1)); | 43 node->ReplaceInput(0, node->InputAt(1)); |
| 44 node->ReplaceInput(1, node->InputAt(2)); | 44 node->ReplaceInput(1, node->InputAt(2)); |
| 45 node->ReplaceInput(2, i->second); | 45 node->ReplaceInput(2, i->second); |
| 46 return Changed(node); | 46 return Changed(node); |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace compiler | 49 } // namespace compiler |
| 50 } // namespace internal | 50 } // namespace internal |
| 51 } // namespace v8 | 51 } // namespace v8 |
| OLD | NEW |