llvm.org GIT mirror llvm / 72415d3
[Tests] Add cases where we're failing to discharge provably loop exits (tests for D63733) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364220 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 2 months ago
1 changed file(s) with 193 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -indvars -S < %s | FileCheck %s
2
3 define void @ult(i64 %n, i64 %m) {
4 ; CHECK-LABEL: @ult(
5 ; CHECK-NEXT: entry:
6 ; CHECK-NEXT: [[CMP0:%.*]] = icmp ult i64 [[N:%.*]], [[M:%.*]]
7 ; CHECK-NEXT: br i1 [[CMP0]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
8 ; CHECK: loop.preheader:
9 ; CHECK-NEXT: br label [[LOOP:%.*]]
10 ; CHECK: loop:
11 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LATCH:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
12 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
13 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[IV]], [[N]]
14 ; CHECK-NEXT: br i1 [[CMP1]], label [[LATCH]], label [[EXIT_LOOPEXIT:%.*]]
15 ; CHECK: latch:
16 ; CHECK-NEXT: call void @side_effect()
17 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i64 [[IV]], [[M]]
18 ; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP]], label [[EXIT_LOOPEXIT]]
19 ; CHECK: exit.loopexit:
20 ; CHECK-NEXT: br label [[EXIT]]
21 ; CHECK: exit:
22 ; CHECK-NEXT: ret void
23 ;
24 entry:
25 %cmp0 = icmp ult i64 %n, %m
26 br i1 %cmp0, label %loop, label %exit
27 loop:
28 %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
29 %iv.next = add i64 %iv, 1
30 %cmp1 = icmp ult i64 %iv, %n
31 br i1 %cmp1, label %latch, label %exit
32 latch:
33 call void @side_effect()
34 %cmp2 = icmp ult i64 %iv, %m
35 br i1 %cmp2, label %loop, label %exit
36 exit:
37 ret void
38 }
39
40 define void @ugt(i64 %n, i64 %m) {
41 ; CHECK-LABEL: @ugt(
42 ; CHECK-NEXT: entry:
43 ; CHECK-NEXT: [[CMP0:%.*]] = icmp ugt i64 [[N:%.*]], [[M:%.*]]
44 ; CHECK-NEXT: br i1 [[CMP0]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
45 ; CHECK: loop.preheader:
46 ; CHECK-NEXT: br label [[LOOP:%.*]]
47 ; CHECK: loop:
48 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LATCH:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
49 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
50 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[IV]], [[N]]
51 ; CHECK-NEXT: br i1 [[CMP1]], label [[LATCH]], label [[EXIT_LOOPEXIT:%.*]]
52 ; CHECK: latch:
53 ; CHECK-NEXT: call void @side_effect()
54 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i64 [[IV]], [[M]]
55 ; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP]], label [[EXIT_LOOPEXIT]]
56 ; CHECK: exit.loopexit:
57 ; CHECK-NEXT: br label [[EXIT]]
58 ; CHECK: exit:
59 ; CHECK-NEXT: ret void
60 ;
61 entry:
62 %cmp0 = icmp ugt i64 %n, %m
63 br i1 %cmp0, label %loop, label %exit
64 loop:
65 %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
66 %iv.next = add i64 %iv, 1
67 %cmp1 = icmp ult i64 %iv, %n
68 br i1 %cmp1, label %latch, label %exit
69 latch:
70 call void @side_effect()
71 %cmp2 = icmp ult i64 %iv, %m
72 br i1 %cmp2, label %loop, label %exit
73 exit:
74 ret void
75 }
76
77 define void @ule(i64 %n, i64 %m) {
78 ; CHECK-LABEL: @ule(
79 ; CHECK-NEXT: entry:
80 ; CHECK-NEXT: [[CMP0:%.*]] = icmp ule i64 [[N:%.*]], [[M:%.*]]
81 ; CHECK-NEXT: br i1 [[CMP0]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
82 ; CHECK: loop.preheader:
83 ; CHECK-NEXT: br label [[LOOP:%.*]]
84 ; CHECK: loop:
85 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LATCH:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
86 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
87 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[IV]], [[N]]
88 ; CHECK-NEXT: br i1 [[CMP1]], label [[LATCH]], label [[EXIT_LOOPEXIT:%.*]]
89 ; CHECK: latch:
90 ; CHECK-NEXT: call void @side_effect()
91 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i64 [[IV]], [[M]]
92 ; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP]], label [[EXIT_LOOPEXIT]]
93 ; CHECK: exit.loopexit:
94 ; CHECK-NEXT: br label [[EXIT]]
95 ; CHECK: exit:
96 ; CHECK-NEXT: ret void
97 ;
98 entry:
99 %cmp0 = icmp ule i64 %n, %m
100 br i1 %cmp0, label %loop, label %exit
101 loop:
102 %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
103 %iv.next = add i64 %iv, 1
104 %cmp1 = icmp ult i64 %iv, %n
105 br i1 %cmp1, label %latch, label %exit
106 latch:
107 call void @side_effect()
108 %cmp2 = icmp ult i64 %iv, %m
109 br i1 %cmp2, label %loop, label %exit
110 exit:
111 ret void
112 }
113
114 define void @uge(i64 %n, i64 %m) {
115 ; CHECK-LABEL: @uge(
116 ; CHECK-NEXT: entry:
117 ; CHECK-NEXT: [[CMP0:%.*]] = icmp uge i64 [[N:%.*]], [[M:%.*]]
118 ; CHECK-NEXT: br i1 [[CMP0]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
119 ; CHECK: loop.preheader:
120 ; CHECK-NEXT: br label [[LOOP:%.*]]
121 ; CHECK: loop:
122 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LATCH:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
123 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
124 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[IV]], [[N]]
125 ; CHECK-NEXT: br i1 [[CMP1]], label [[LATCH]], label [[EXIT_LOOPEXIT:%.*]]
126 ; CHECK: latch:
127 ; CHECK-NEXT: call void @side_effect()
128 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i64 [[IV]], [[M]]
129 ; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP]], label [[EXIT_LOOPEXIT]]
130 ; CHECK: exit.loopexit:
131 ; CHECK-NEXT: br label [[EXIT]]
132 ; CHECK: exit:
133 ; CHECK-NEXT: ret void
134 ;
135 entry:
136 %cmp0 = icmp uge i64 %n, %m
137 br i1 %cmp0, label %loop, label %exit
138 loop:
139 %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
140 %iv.next = add i64 %iv, 1
141 %cmp1 = icmp ult i64 %iv, %n
142 br i1 %cmp1, label %latch, label %exit
143 latch:
144 call void @side_effect()
145 %cmp2 = icmp ult i64 %iv, %m
146 br i1 %cmp2, label %loop, label %exit
147 exit:
148 ret void
149 }
150
151
152 define void @ult_const_max(i64 %n) {
153 ; CHECK-LABEL: @ult_const_max(
154 ; CHECK-NEXT: entry:
155 ; CHECK-NEXT: [[CMP0:%.*]] = icmp ult i64 [[N:%.*]], 20
156 ; CHECK-NEXT: br i1 [[CMP0]], label [[LOOP_PREHEADER:%.*]], label [[EXIT:%.*]]
157 ; CHECK: loop.preheader:
158 ; CHECK-NEXT: br label [[LOOP:%.*]]
159 ; CHECK: loop:
160 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], [[LATCH:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
161 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
162 ; CHECK-NEXT: [[UDIV:%.*]] = udiv i64 [[IV]], 10
163 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[UDIV]], 2
164 ; CHECK-NEXT: br i1 [[CMP1]], label [[LATCH]], label [[EXIT_LOOPEXIT:%.*]]
165 ; CHECK: latch:
166 ; CHECK-NEXT: call void @side_effect()
167 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i64 [[IV]], [[N]]
168 ; CHECK-NEXT: br i1 [[CMP2]], label [[LOOP]], label [[EXIT_LOOPEXIT]]
169 ; CHECK: exit.loopexit:
170 ; CHECK-NEXT: br label [[EXIT]]
171 ; CHECK: exit:
172 ; CHECK-NEXT: ret void
173 ;
174 entry:
175 %cmp0 = icmp ult i64 %n, 20
176 br i1 %cmp0, label %loop, label %exit
177 loop:
178 %iv = phi i64 [ 0, %entry ], [ %iv.next, %latch ]
179 %iv.next = add i64 %iv, 1
180 %udiv = udiv i64 %iv, 10
181 %cmp1 = icmp ult i64 %udiv, 2
182 br i1 %cmp1, label %latch, label %exit
183 latch:
184 call void @side_effect()
185 %cmp2 = icmp ult i64 %iv, %n
186 br i1 %cmp2, label %loop, label %exit
187 exit:
188 ret void
189 }
190
191
192 declare void @side_effect()