diff options
Diffstat (limited to 'deps/v8/test/unittests/compiler/branch-elimination-unittest.cc')
-rw-r--r-- | deps/v8/test/unittests/compiler/branch-elimination-unittest.cc | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/deps/v8/test/unittests/compiler/branch-elimination-unittest.cc b/deps/v8/test/unittests/compiler/branch-elimination-unittest.cc index 34fb84957c..a231539f6f 100644 --- a/deps/v8/test/unittests/compiler/branch-elimination-unittest.cc +++ b/deps/v8/test/unittests/compiler/branch-elimination-unittest.cc @@ -39,7 +39,6 @@ class BranchEliminationTest : public GraphTest { MachineOperatorBuilder machine_; }; - TEST_F(BranchEliminationTest, NestedBranchSameTrue) { // { return (x ? (x ? 1 : 2) : 3; } // should be reduced to @@ -80,7 +79,6 @@ TEST_F(BranchEliminationTest, NestedBranchSameTrue) { IsInt32Constant(2), IsMerge(outer_if_true, IsDead()))); } - TEST_F(BranchEliminationTest, NestedBranchSameFalse) { // { return (x ? 1 : (x ? 2 : 3); } // should be reduced to @@ -122,10 +120,9 @@ TEST_F(BranchEliminationTest, NestedBranchSameFalse) { IsInt32Constant(3), IsMerge(IsDead(), outer_if_false))); } - TEST_F(BranchEliminationTest, BranchAfterDiamond) { // { var y = x ? 1 : 2; return y + x ? 3 : 4; } - // should not be reduced. + // second branch's condition should be replaced with a phi. Node* condition = Parameter(0); Node* branch1 = @@ -136,7 +133,7 @@ TEST_F(BranchEliminationTest, BranchAfterDiamond) { Node* phi1 = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), Int32Constant(1), Int32Constant(2), merge1); - + // Second branch use the same condition. Node* branch2 = graph()->NewNode(common()->Branch(), condition, merge1); Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); @@ -145,7 +142,6 @@ TEST_F(BranchEliminationTest, BranchAfterDiamond) { graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), Int32Constant(3), Int32Constant(4), merge1); - Node* add = graph()->NewNode(machine()->Int32Add(), phi1, phi2); Node* zero = graph()->NewNode(common()->Int32Constant(0)); Node* ret = @@ -154,13 +150,13 @@ TEST_F(BranchEliminationTest, BranchAfterDiamond) { Reduce(); - // Outer branch should not be rewritten, the inner branch condition should - // be true. - EXPECT_THAT(branch1, IsBranch(condition, graph()->start())); - EXPECT_THAT(branch2, IsBranch(condition, merge1)); + // The branch condition for branch2 should be a phi with constants. + EXPECT_THAT(branch2, + IsBranch(IsPhi(MachineRepresentation::kWord32, IsInt32Constant(1), + IsInt32Constant(0), merge1), + merge1)); } - TEST_F(BranchEliminationTest, BranchInsideLoopSame) { // if (x) while (x) { return 2; } else { return 1; } // should be rewritten to @@ -172,7 +168,6 @@ TEST_F(BranchEliminationTest, BranchInsideLoopSame) { graph()->NewNode(common()->Branch(), condition, graph()->start()); Node* outer_if_true = graph()->NewNode(common()->IfTrue(), outer_branch); - Node* loop = graph()->NewNode(common()->Loop(1), outer_if_true); Node* effect = graph()->NewNode(common()->EffectPhi(1), graph()->start(), loop); |