OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/compiler/select-lowering.h" |
| 6 #include "test/unittests/compiler/graph-unittest.h" |
| 7 #include "test/unittests/compiler/node-test-utils.h" |
| 8 #include "testing/gmock-support.h" |
| 9 |
| 10 using testing::AllOf; |
| 11 using testing::Capture; |
| 12 using testing::CaptureEq; |
| 13 |
| 14 namespace v8 { |
| 15 namespace internal { |
| 16 namespace compiler { |
| 17 |
| 18 class SelectLoweringTest : public GraphTest { |
| 19 public: |
| 20 SelectLoweringTest() : GraphTest(5), lowering_(graph(), common()) {} |
| 21 |
| 22 protected: |
| 23 Reduction Reduce(Node* node) { return lowering_.Reduce(node); } |
| 24 |
| 25 private: |
| 26 SelectLowering lowering_; |
| 27 }; |
| 28 |
| 29 |
| 30 TEST_F(SelectLoweringTest, SelectWithSameConditions) { |
| 31 Node* const p0 = Parameter(0); |
| 32 Node* const p1 = Parameter(1); |
| 33 Node* const p2 = Parameter(2); |
| 34 Node* const p3 = Parameter(3); |
| 35 Node* const p4 = Parameter(4); |
| 36 |
| 37 Capture<Node*> branch; |
| 38 Capture<Node*> merge; |
| 39 { |
| 40 Reduction const r = |
| 41 Reduce(graph()->NewNode(common()->Select(kMachInt32), p0, p1, p2)); |
| 42 ASSERT_TRUE(r.Changed()); |
| 43 EXPECT_THAT( |
| 44 r.replacement(), |
| 45 IsPhi( |
| 46 kMachInt32, p1, p2, |
| 47 AllOf(CaptureEq(&merge), |
| 48 IsMerge(IsIfTrue(CaptureEq(&branch)), |
| 49 IsIfFalse(AllOf(CaptureEq(&branch), |
| 50 IsBranch(p0, graph()->start()))))))); |
| 51 } |
| 52 { |
| 53 Reduction const r = |
| 54 Reduce(graph()->NewNode(common()->Select(kMachInt32), p0, p3, p4)); |
| 55 ASSERT_TRUE(r.Changed()); |
| 56 EXPECT_THAT(r.replacement(), IsPhi(kMachInt32, p3, p4, CaptureEq(&merge))); |
| 57 } |
| 58 } |
| 59 |
| 60 } // namespace compiler |
| 61 } // namespace internal |
| 62 } // namespace v8 |
OLD | NEW |