• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %s -S -simplifycfg | FileCheck %s
2
3declare void @is(i1)
4
5; If A == B is false then A == B is implied false.
6; CHECK-LABEL: @test_eq_eq
7; CHECK-NOT: call void @is(i1 true)
8; CHECK: call void @is(i1 false)
9define void @test_eq_eq(i32 %a, i32 %b) {
10  %cmp1 = icmp eq i32 %a, %b
11  br i1 %cmp1, label %untaken, label %taken
12
13taken:
14  %cmp2 = icmp eq i32 %a, %b
15  br i1 %cmp2, label %istrue, label %isfalse
16
17istrue:
18  call void @is(i1 true)
19  ret void
20
21isfalse:
22  call void @is(i1 false)
23  ret void
24
25untaken:
26  ret void
27}
28
29; If A == B is false then A != B is implied true.
30; CHECK-LABEL: @test_eq_ne
31; CHECK: call void @is(i1 true)
32; CHECK-NOT: call void @is(i1 false)
33define void @test_eq_ne(i32 %a, i32 %b) {
34  %cmp1 = icmp eq i32 %a, %b
35  br i1 %cmp1, label %untaken, label %taken
36
37taken:
38  %cmp2 = icmp ne i32 %a, %b
39  br i1 %cmp2, label %istrue, label %isfalse
40
41istrue:
42  call void @is(i1 true)
43  ret void
44
45isfalse:
46  call void @is(i1 false)
47  ret void
48
49untaken:
50  ret void
51}
52
53; If A != B is false then A != B is implied false.
54; CHECK-LABEL: @test_ne_ne
55; CHECK-NOT: call void @is(i1 true)
56; CHECK: call void @is(i1 false)
57define void @test_ne_ne(i32 %a, i32 %b) {
58  %cmp1 = icmp ne i32 %a, %b
59  br i1 %cmp1, label %untaken, label %taken
60
61taken:
62  %cmp2 = icmp ne i32 %a, %b
63  br i1 %cmp2, label %istrue, label %isfalse
64
65istrue:
66  call void @is(i1 true)
67  ret void
68
69isfalse:
70  call void @is(i1 false)
71  ret void
72
73untaken:
74  ret void
75}
76
77; If A != B is false then A >u B is implied false.
78; CHECK-LABEL: @test_ne_ugt
79; CHECK-NOT: call void @is(i1 true)
80; CHECK: call void @is(i1 false)
81define void @test_ne_ugt(i32 %a, i32 %b) {
82  %cmp1 = icmp ne i32 %a, %b
83  br i1 %cmp1, label %untaken, label %taken
84
85taken:
86  %cmp2 = icmp ugt i32 %a, %b
87  br i1 %cmp2, label %istrue, label %isfalse
88
89istrue:
90  call void @is(i1 true)
91  ret void
92
93isfalse:
94  call void @is(i1 false)
95  ret void
96
97untaken:
98  ret void
99}
100
101; If A != B is false then A >=u B is implied true.
102; CHECK-LABEL: @test_ne_uge
103; CHECK: call void @is(i1 true)
104; CHECK-NOT: call void @is(i1 false)
105define void @test_ne_uge(i32 %a, i32 %b) {
106  %cmp1 = icmp ne i32 %a, %b
107  br i1 %cmp1, label %untaken, label %taken
108
109taken:
110  %cmp2 = icmp uge i32 %a, %b
111  br i1 %cmp2, label %istrue, label %isfalse
112
113istrue:
114  call void @is(i1 true)
115  ret void
116
117isfalse:
118  call void @is(i1 false)
119  ret void
120
121untaken:
122  ret void
123}
124
125; If A != B is false then A <u B is implied false.
126; CHECK-LABEL: @test_ne_ult
127; CHECK-NOT: call void @is(i1 true)
128; CHECK: call void @is(i1 false)
129define void @test_ne_ult(i32 %a, i32 %b) {
130  %cmp1 = icmp ne i32 %a, %b
131  br i1 %cmp1, label %untaken, label %taken
132
133taken:
134  %cmp2 = icmp ult i32 %a, %b
135  br i1 %cmp2, label %istrue, label %isfalse
136
137istrue:
138  call void @is(i1 true)
139  ret void
140
141isfalse:
142  call void @is(i1 false)
143  ret void
144
145untaken:
146  ret void
147}
148
149; If A != B is false then A <=u B is implied true.
150; CHECK-LABEL: @test_ne_ule
151; CHECK: call void @is(i1 true)
152; CHECK-NOT: call void @is(i1 false)
153define void @test_ne_ule(i32 %a, i32 %b) {
154  %cmp1 = icmp ne i32 %a, %b
155  br i1 %cmp1, label %untaken, label %taken
156
157taken:
158  %cmp2 = icmp ule i32 %a, %b
159  br i1 %cmp2, label %istrue, label %isfalse
160
161istrue:
162  call void @is(i1 true)
163  ret void
164
165isfalse:
166  call void @is(i1 false)
167  ret void
168
169untaken:
170  ret void
171}
172
173; If A >u B is false then A >u B is implied false.
174; CHECK-LABEL: @test_ugt_ugt
175; CHECK-NOT: call void @is(i1 true)
176; CHECK: call void @is(i1 false)
177define void @test_ugt_ugt(i32 %a, i32 %b) {
178  %cmp1 = icmp ugt i32 %a, %b
179  br i1 %cmp1, label %untaken, label %taken
180
181taken:
182  %cmp2 = icmp ugt i32 %a, %b
183  br i1 %cmp2, label %istrue, label %isfalse
184
185istrue:
186  call void @is(i1 true)
187  ret void
188
189isfalse:
190  call void @is(i1 false)
191  ret void
192
193untaken:
194  ret void
195}
196
197; If A >u B is false then A <=u B is implied true.
198; CHECK-LABEL: @test_ugt_ule
199; CHECK: call void @is(i1 true)
200; CHECK-NOT: call void @is(i1 false)
201define void @test_ugt_ule(i32 %a, i32 %b) {
202  %cmp1 = icmp ugt i32 %a, %b
203  br i1 %cmp1, label %untaken, label %taken
204
205taken:
206  %cmp2 = icmp ule i32 %a, %b
207  br i1 %cmp2, label %istrue, label %isfalse
208
209istrue:
210  call void @is(i1 true)
211  ret void
212
213isfalse:
214  call void @is(i1 false)
215  ret void
216
217untaken:
218  ret void
219}
220
221; If A >=u B is false then A >=u B is implied false.
222; CHECK-LABEL: @test_uge_uge
223; CHECK-NOT: call void @is(i1 true)
224; CHECK: call void @is(i1 false)
225define void @test_uge_uge(i32 %a, i32 %b) {
226  %cmp1 = icmp uge i32 %a, %b
227  br i1 %cmp1, label %untaken, label %taken
228
229taken:
230  %cmp2 = icmp uge i32 %a, %b
231  br i1 %cmp2, label %istrue, label %isfalse
232
233istrue:
234  call void @is(i1 true)
235  ret void
236
237isfalse:
238  call void @is(i1 false)
239  ret void
240
241untaken:
242  ret void
243}
244
245; If A >=u B is false then A <u B is implied true.
246; CHECK-LABEL: @test_uge_ult
247; CHECK: call void @is(i1 true)
248; CHECK-NOT: call void @is(i1 false)
249define void @test_uge_ult(i32 %a, i32 %b) {
250  %cmp1 = icmp uge i32 %a, %b
251  br i1 %cmp1, label %untaken, label %taken
252
253taken:
254  %cmp2 = icmp ult i32 %a, %b
255  br i1 %cmp2, label %istrue, label %isfalse
256
257istrue:
258  call void @is(i1 true)
259  ret void
260
261isfalse:
262  call void @is(i1 false)
263  ret void
264
265untaken:
266  ret void
267}
268
269; If A >=u B is false then A <=u B is implied true.
270; CHECK-LABEL: @test_uge_ule
271; CHECK: call void @is(i1 true)
272; CHECK-NOT: call void @is(i1 false)
273define void @test_uge_ule(i32 %a, i32 %b) {
274  %cmp1 = icmp uge i32 %a, %b
275  br i1 %cmp1, label %untaken, label %taken
276
277taken:
278  %cmp2 = icmp ule i32 %a, %b
279  br i1 %cmp2, label %istrue, label %isfalse
280
281istrue:
282  call void @is(i1 true)
283  ret void
284
285isfalse:
286  call void @is(i1 false)
287  ret void
288
289untaken:
290  ret void
291}
292
293; If A <u B is false then A <u B is implied false.
294; CHECK-LABEL: @test_ult_ult
295; CHECK-NOT: call void @is(i1 true)
296; CHECK: call void @is(i1 false)
297define void @test_ult_ult(i32 %a, i32 %b) {
298  %cmp1 = icmp ult i32 %a, %b
299  br i1 %cmp1, label %untaken, label %taken
300
301taken:
302  %cmp2 = icmp ult i32 %a, %b
303  br i1 %cmp2, label %istrue, label %isfalse
304
305istrue:
306  call void @is(i1 true)
307  ret void
308
309isfalse:
310  call void @is(i1 false)
311  ret void
312
313untaken:
314  ret void
315}
316
317; If A <=u B is false then A <=u B is implied false.
318; CHECK-LABEL: @test_ule_ule
319; CHECK-NOT: call void @is(i1 true)
320; CHECK: call void @is(i1 false)
321define void @test_ule_ule(i32 %a, i32 %b) {
322  %cmp1 = icmp ule i32 %a, %b
323  br i1 %cmp1, label %untaken, label %taken
324
325taken:
326  %cmp2 = icmp ule i32 %a, %b
327  br i1 %cmp2, label %istrue, label %isfalse
328
329istrue:
330  call void @is(i1 true)
331  ret void
332
333isfalse:
334  call void @is(i1 false)
335  ret void
336
337untaken:
338  ret void
339}
340