llvm.org GIT mirror llvm / abe4967
[LoopDeletion] (cleanup, NFC) Make this test actually test what it claims to test. LoopSimplify was unifying the multiple exits in this test case, making it never even test the multiple exit handling of LoopDeletion. Doh. Now it works (thanks to a great idea from mkuper) and will fail if we ever change something to make it stop working. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292331 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 2 years ago
1 changed file(s) with 72 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
None ; RUN: opt < %s -loop-deletion -S | FileCheck %s
0 ; Checks whether dead loops with multiple exits can be eliminated.
1 ; Note that we loop simplify and LCSSA over the test cases to make sure the
2 ; critical components remain after those passes and are visible to the loop
3 ; deletion pass.
4 ;
5 ; RUN: opt < %s -loop-simplify -lcssa -S | FileCheck %s --check-prefixes=CHECK,BEFORE
6 ; RUN: opt < %s -loop-deletion -S | FileCheck %s --check-prefixes=CHECK,AFTER
17
2 ; Checks whether dead loops with multiple exits can be eliminated
38
49 define void @foo(i64 %n, i64 %m) nounwind {
510 ; CHECK-LABEL: @foo(
6 ; CHECK: entry:
7 ; CHECK-NEXT: br label %return
811
9 ; CHECK: return:
10 ; CHECK-NEXT: ret void
1112 entry:
1213 br label %bb
14 ; CHECK: entry:
15 ; BEFORE-NEXT: br label %bb
16 ; AFTER-NEXT: br label %return
1317
1418 bb:
1519 %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb2 ]
1620 %t0 = add i64 %x.0, 1
1721 %t1 = icmp slt i64 %x.0, %n
1822 br i1 %t1, label %bb2, label %return
23 ; BEFORE: bb:
24 ; BEFORE: br i1 {{.*}}, label %bb2, label %return
25 ; AFTER-NOT: bb:
26 ; AFTER-NOT: br
27
1928 bb2:
2029 %t2 = icmp slt i64 %x.0, %m
2130 br i1 %t1, label %bb, label %return
31 ; BEFORE: bb2:
32 ; BEFORE: br i1 {{.*}}, label %bb, label %return
33 ; AFTER-NOT: bb2:
34 ; AFTER-NOT: br
2235
2336 return:
2437 ret void
38 ; CHECK: return:
39 ; CHECK-NEXT: ret void
2540 }
2641
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
42 define i64 @bar(i64 %n, i64 %m, i64 %maybe_zero) nounwind {
43 ; CHECK-LABEL: @bar(
3444
3545 entry:
3646 br label %bb
47 ; CHECK: entry:
48 ; BEFORE-NEXT: br label %bb
49 ; AFTER-NEXT: br label %return
3750
3851 bb:
3952 %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb3 ]
4053 %t0 = add i64 %x.0, 1
4154 %t1 = icmp slt i64 %x.0, %n
4255 br i1 %t1, label %bb2, label %return
56 ; BEFORE: bb:
57 ; BEFORE: br i1 {{.*}}, label %bb2, label %return
58 ; AFTER-NOT: bb:
59 ; AFTER-NOT: br
60
4361 bb2:
4462 %t2 = icmp slt i64 %x.0, %m
63 ; This unused division prevents unifying this loop exit path with others
64 ; because it can be deleted but cannot be hoisted.
65 %unused1 = udiv i64 42, %maybe_zero
4566 br i1 %t2, label %bb3, label %return
67 ; BEFORE: bb2:
68 ; BEFORE: br i1 {{.*}}, label %bb3, label %return
69 ; AFTER-NOT: bb2:
70 ; AFTER-NOT: br
71
4672 bb3:
4773 %t3 = icmp slt i64 %x.0, %m
74 ; This unused division prevents unifying this loop exit path with others
75 ; because it can be deleted but cannot be hoisted.
76 %unused2 = sdiv i64 42, %maybe_zero
4877 br i1 %t3, label %bb, label %return
78 ; BEFORE: bb3:
79 ; BEFORE: br i1 {{.*}}, label %bb, label %return
80 ; AFTER-NOT: bb3:
81 ; AFTER-NOT: br
4982
5083 return:
5184 %x.lcssa = phi i64 [ 10, %bb ], [ 10, %bb2 ], [ 10, %bb3 ]
5285 ret i64 %x.lcssa
86 ; CHECK: return:
87 ; BEFORE-NEXT: %[[X:.*]] = phi i64 [ 10, %bb ], [ 10, %bb2 ], [ 10, %bb3 ]
88 ; AFTER-NEXT: %[[X:.*]] = phi i64 [ 10, %entry ]
89 ; CHECK-NEXT: ret i64 %[[X]]
5390 }
5491
55 define i64 @baz(i64 %n, i64 %m) nounwind {
92 ; This function has a loop which looks like @bar's but that cannot be deleted
93 ; because which path we exit through determines which value is selected.
94 define i64 @baz(i64 %n, i64 %m, i64 %maybe_zero) nounwind {
5695 ; CHECK-LABEL: @baz(
57 ; CHECK: return:
58 ; CHECK-NEXT: %x.lcssa = phi i64 [ 12, %bb ], [ 10, %bb2 ]
59 ; CHECK-NEXT: ret i64 %x.lcssa
6096
6197 entry:
6298 br label %bb
99 ; CHECK: entry:
100 ; CHECK-NEXT: br label %bb
63101
64102 bb:
65103 %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb3 ]
66104 %t0 = add i64 %x.0, 1
67105 %t1 = icmp slt i64 %x.0, %n
68106 br i1 %t1, label %bb2, label %return
107 ; CHECK: bb:
108 ; CHECK: br i1 {{.*}}, label %bb2, label %return
109
69110 bb2:
70111 %t2 = icmp slt i64 %x.0, %m
112 ; This unused division prevents unifying this loop exit path with others
113 ; because it can be deleted but cannot be hoisted.
114 %unused1 = udiv i64 42, %maybe_zero
71115 br i1 %t2, label %bb3, label %return
116 ; CHECK: bb2:
117 ; CHECK: br i1 {{.*}}, label %bb3, label %return
118
72119 bb3:
73120 %t3 = icmp slt i64 %x.0, %m
121 ; This unused division prevents unifying this loop exit path with others
122 ; because it can be deleted but cannot be hoisted.
123 %unused2 = sdiv i64 42, %maybe_zero
74124 br i1 %t3, label %bb, label %return
125 ; CHECK: bb3:
126 ; CHECK: br i1 {{.*}}, label %bb, label %return
75127
76128 return:
77129 %x.lcssa = phi i64 [ 12, %bb ], [ 10, %bb2 ], [ 10, %bb3 ]
78130 ret i64 %x.lcssa
131 ; CHECK: return:
132 ; CHECK-NEXT: %[[X:.*]] = phi i64 [ 12, %bb ], [ 10, %bb2 ], [ 10, %bb3 ]
133 ; CHECK-NEXT: ret i64 %[[X]]
79134 }