| 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.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/common-operator-reducer.h" | 6 #include "src/compiler/common-operator-reducer.h" |
| 7 #include "src/compiler/machine-operator.h" | 7 #include "src/compiler/machine-operator.h" |
| 8 #include "src/compiler/machine-type.h" | 8 #include "src/compiler/machine-type.h" |
| 9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
| 10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge); | 418 Node* phi = graph()->NewNode(common()->Phi(kMachFloat64, 2), p0, p1, merge); |
| 419 StrictMock<MockAdvancedReducerEditor> editor; | 419 StrictMock<MockAdvancedReducerEditor> editor; |
| 420 EXPECT_CALL(editor, Revisit(merge)); | 420 EXPECT_CALL(editor, Revisit(merge)); |
| 421 Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Min); | 421 Reduction r = Reduce(&editor, phi, MachineOperatorBuilder::kFloat64Min); |
| 422 ASSERT_TRUE(r.Changed()); | 422 ASSERT_TRUE(r.Changed()); |
| 423 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); | 423 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); |
| 424 } | 424 } |
| 425 | 425 |
| 426 | 426 |
| 427 // ----------------------------------------------------------------------------- | 427 // ----------------------------------------------------------------------------- |
| 428 // Return |
| 429 |
| 430 |
| 431 TEST_F(CommonOperatorReducerTest, ReturnWithPhiAndEffectPhiAndMerge) { |
| 432 Node* cond = Parameter(2); |
| 433 Node* branch = graph()->NewNode(common()->Branch(), cond, graph()->start()); |
| 434 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 435 Node* etrue = graph()->start(); |
| 436 Node* vtrue = Parameter(0); |
| 437 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
| 438 Node* efalse = graph()->start(); |
| 439 Node* vfalse = Parameter(1); |
| 440 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
| 441 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); |
| 442 Node* phi = |
| 443 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), vtrue, vfalse, merge); |
| 444 Node* ret = graph()->NewNode(common()->Return(), phi, ephi, merge); |
| 445 graph()->SetEnd(graph()->NewNode(common()->End(1), ret)); |
| 446 StrictMock<MockAdvancedReducerEditor> editor; |
| 447 EXPECT_CALL(editor, Replace(merge, IsDead())); |
| 448 Reduction const r = Reduce(&editor, ret); |
| 449 ASSERT_TRUE(r.Changed()); |
| 450 EXPECT_THAT(r.replacement(), IsDead()); |
| 451 EXPECT_THAT(graph()->end(), IsEnd(ret, IsReturn(vtrue, etrue, if_true), |
| 452 IsReturn(vfalse, efalse, if_false))); |
| 453 } |
| 454 |
| 455 |
| 456 // ----------------------------------------------------------------------------- |
| 428 // Select | 457 // Select |
| 429 | 458 |
| 430 | 459 |
| 431 TEST_F(CommonOperatorReducerTest, SelectWithSameThenAndElse) { | 460 TEST_F(CommonOperatorReducerTest, SelectWithSameThenAndElse) { |
| 432 Node* const input = graph()->NewNode(&kOp0); | 461 Node* const input = graph()->NewNode(&kOp0); |
| 433 TRACED_FOREACH(BranchHint, hint, kBranchHints) { | 462 TRACED_FOREACH(BranchHint, hint, kBranchHints) { |
| 434 TRACED_FOREACH(MachineType, type, kMachineTypes) { | 463 TRACED_FOREACH(MachineType, type, kMachineTypes) { |
| 435 Reduction r = Reduce( | 464 Reduction r = Reduce( |
| 436 graph()->NewNode(common()->Select(type, hint), input, input, input)); | 465 graph()->NewNode(common()->Select(type, hint), input, input, input)); |
| 437 ASSERT_TRUE(r.Changed()); | 466 ASSERT_TRUE(r.Changed()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 Node* select = | 605 Node* select = |
| 577 graph()->NewNode(common()->Select(kMachFloat64), check, p0, p1); | 606 graph()->NewNode(common()->Select(kMachFloat64), check, p0, p1); |
| 578 Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Min); | 607 Reduction r = Reduce(select, MachineOperatorBuilder::kFloat64Min); |
| 579 ASSERT_TRUE(r.Changed()); | 608 ASSERT_TRUE(r.Changed()); |
| 580 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); | 609 EXPECT_THAT(r.replacement(), IsFloat64Min(p0, p1)); |
| 581 } | 610 } |
| 582 | 611 |
| 583 } // namespace compiler | 612 } // namespace compiler |
| 584 } // namespace internal | 613 } // namespace internal |
| 585 } // namespace v8 | 614 } // namespace v8 |
| OLD | NEW |