llvm.org GIT mirror llvm / 26fc301
Use all_of instead of a raw loop; NFC Added some tests despite being NFC, since it looks like nothing was exercising the "all incoming values to exit PHIs are same" logic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268407 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjoy Das 3 years ago
2 changed file(s) with 60 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
8585 // block. If there are different incoming values for different exiting
8686 // blocks, then it is impossible to statically determine which value should
8787 // be used.
88 for (unsigned i = 1, e = exitingBlocks.size(); i < e; ++i) {
89 if (incoming != P->getIncomingValueForBlock(exitingBlocks[i])) {
90 AllOutgoingValuesSame = false;
91 break;
92 }
93 }
88 AllOutgoingValuesSame =
89 all_of(makeArrayRef(exitingBlocks).slice(1), [&](BasicBlock *BB) {
90 return incoming == P->getIncomingValueForBlock(BB);
91 });
9492
9593 if (!AllOutgoingValuesSame)
9694 break;
11
22 ; Checks whether dead loops with multiple exits can be eliminated
33
4 define void @foo(i64 %n, i64 %m) nounwind {
5 ; CHECK-LABEL: @foo(
46 ; CHECK: entry:
57 ; CHECK-NEXT: br label %return
68
79 ; CHECK: return:
810 ; CHECK-NEXT: ret void
9
10 define void @foo(i64 %n, i64 %m) nounwind {
1111 entry:
1212 br label %bb
1313
2323 return:
2424 ret void
2525 }
26
27 define i64 @bar(i64 %n, i64 %m) nounwind {
28 ; CHECK-LABEL: @bar(
29 ; CHECK: entry:
30 ; CHECK-NEXT: br label %return
31
32 ; CHECK: return:
33 ; CHECK-NEXT: ret i64 10
34
35 entry:
36 br label %bb
37
38 bb:
39 %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb3 ]
40 %t0 = add i64 %x.0, 1
41 %t1 = icmp slt i64 %x.0, %n
42 br i1 %t1, label %bb2, label %return
43 bb2:
44 %t2 = icmp slt i64 %x.0, %m
45 br i1 %t2, label %bb3, label %return
46 bb3:
47 %t3 = icmp slt i64 %x.0, %m
48 br i1 %t3, label %bb, label %return
49
50 return:
51 %x.lcssa = phi i64 [ 10, %bb ], [ 10, %bb2 ], [ 10, %bb3 ]
52 ret i64 %x.lcssa
53 }
54
55 define i64 @baz(i64 %n, i64 %m) nounwind {
56 ; CHECK-LABEL: @baz(
57 ; CHECK: return:
58 ; CHECK-NEXT: %x.lcssa = phi i64 [ 12, %bb ], [ 10, %bb2 ]
59 ; CHECK-NEXT: ret i64 %x.lcssa
60
61 entry:
62 br label %bb
63
64 bb:
65 %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb3 ]
66 %t0 = add i64 %x.0, 1
67 %t1 = icmp slt i64 %x.0, %n
68 br i1 %t1, label %bb2, label %return
69 bb2:
70 %t2 = icmp slt i64 %x.0, %m
71 br i1 %t2, label %bb3, label %return
72 bb3:
73 %t3 = icmp slt i64 %x.0, %m
74 br i1 %t3, label %bb, label %return
75
76 return:
77 %x.lcssa = phi i64 [ 12, %bb ], [ 10, %bb2 ], [ 10, %bb3 ]
78 ret i64 %x.lcssa
79 }