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/common-operator-reducer.h" | 5 #include "src/compiler/common-operator-reducer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 use->set_op(common()->IfTrue()); | 92 use->set_op(common()->IfTrue()); |
93 break; | 93 break; |
94 default: | 94 default: |
95 UNREACHABLE(); | 95 UNREACHABLE(); |
96 } | 96 } |
97 } | 97 } |
98 // Update the condition of {branch}. No need to mark the uses for revisit, | 98 // Update the condition of {branch}. No need to mark the uses for revisit, |
99 // since we tell the graph reducer that the {branch} was changed and the | 99 // since we tell the graph reducer that the {branch} was changed and the |
100 // graph reduction logic will ensure that the uses are revisited properly. | 100 // graph reduction logic will ensure that the uses are revisited properly. |
101 node->ReplaceInput(0, cond->InputAt(0)); | 101 node->ReplaceInput(0, cond->InputAt(0)); |
| 102 // Negate the hint for {branch}. |
| 103 node->set_op(common()->Branch(NegateBranchHint(BranchHintOf(node->op())))); |
102 return Changed(node); | 104 return Changed(node); |
103 } | 105 } |
104 Decision const decision = DecideCondition(cond); | 106 Decision const decision = DecideCondition(cond); |
105 if (decision == Decision::kUnknown) return NoChange(); | 107 if (decision == Decision::kUnknown) return NoChange(); |
106 Node* const control = node->InputAt(1); | 108 Node* const control = node->InputAt(1); |
107 for (Node* const use : node->uses()) { | 109 for (Node* const use : node->uses()) { |
108 switch (use->opcode()) { | 110 switch (use->opcode()) { |
109 case IrOpcode::kIfTrue: | 111 case IrOpcode::kIfTrue: |
110 Replace(use, (decision == Decision::kTrue) ? control : dead()); | 112 Replace(use, (decision == Decision::kTrue) ? control : dead()); |
111 break; | 113 break; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 node->set_op(op); | 374 node->set_op(op); |
373 node->ReplaceInput(0, a); | 375 node->ReplaceInput(0, a); |
374 node->ReplaceInput(1, b); | 376 node->ReplaceInput(1, b); |
375 node->TrimInputCount(2); | 377 node->TrimInputCount(2); |
376 return Changed(node); | 378 return Changed(node); |
377 } | 379 } |
378 | 380 |
379 } // namespace compiler | 381 } // namespace compiler |
380 } // namespace internal | 382 } // namespace internal |
381 } // namespace v8 | 383 } // namespace v8 |
OLD | NEW |