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/control-flow-optimizer.h" | 5 #include "src/compiler/control-flow-optimizer.h" |
6 | 6 |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 if (m1.left().node() != index) break; | 238 if (m1.left().node() != index) break; |
239 if (!m1.right().HasValue()) break; | 239 if (!m1.right().HasValue()) break; |
240 int32_t value1 = m1.right().Value(); | 240 int32_t value1 = m1.right().Value(); |
241 if (values.find(value1) != values.end()) break; | 241 if (values.find(value1) != values.end()) break; |
242 DCHECK_NE(value, value1); | 242 DCHECK_NE(value, value1); |
243 | 243 |
244 if (branch != node) { | 244 if (branch != node) { |
245 branch->NullAllInputs(); | 245 branch->NullAllInputs(); |
246 if_true->ReplaceInput(0, node); | 246 if_true->ReplaceInput(0, node); |
247 } | 247 } |
248 if_true->set_op(common()->IfValue(value)); | 248 NodeProperties::ChangeOp(if_true, common()->IfValue(value)); |
249 if_false->NullAllInputs(); | 249 if_false->NullAllInputs(); |
250 Enqueue(if_true); | 250 Enqueue(if_true); |
251 | 251 |
252 branch = branch1; | 252 branch = branch1; |
253 value = value1; | 253 value = value1; |
254 values.insert(value); | 254 values.insert(value); |
255 } | 255 } |
256 | 256 |
257 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); | 257 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); |
258 DCHECK_EQ(IrOpcode::kBranch, branch->opcode()); | 258 DCHECK_EQ(IrOpcode::kBranch, branch->opcode()); |
259 if (branch == node) { | 259 if (branch == node) { |
260 DCHECK_EQ(1u, values.size()); | 260 DCHECK_EQ(1u, values.size()); |
261 return false; | 261 return false; |
262 } | 262 } |
263 DCHECK_LT(1u, values.size()); | 263 DCHECK_LT(1u, values.size()); |
264 node->set_op(common()->Switch(values.size() + 1)); | |
265 node->ReplaceInput(0, index); | 264 node->ReplaceInput(0, index); |
266 if_true->set_op(common()->IfValue(value)); | 265 NodeProperties::ChangeOp(node, common()->Switch(values.size() + 1)); |
267 if_true->ReplaceInput(0, node); | 266 if_true->ReplaceInput(0, node); |
| 267 NodeProperties::ChangeOp(if_true, common()->IfValue(value)); |
268 Enqueue(if_true); | 268 Enqueue(if_true); |
269 if_false->set_op(common()->IfDefault()); | |
270 if_false->ReplaceInput(0, node); | 269 if_false->ReplaceInput(0, node); |
| 270 NodeProperties::ChangeOp(if_false, common()->IfDefault()); |
271 Enqueue(if_false); | 271 Enqueue(if_false); |
272 branch->NullAllInputs(); | 272 branch->NullAllInputs(); |
273 return true; | 273 return true; |
274 } | 274 } |
275 | 275 |
276 } // namespace compiler | 276 } // namespace compiler |
277 } // namespace internal | 277 } // namespace internal |
278 } // namespace v8 | 278 } // namespace v8 |
OLD | NEW |