1 ; RUN: opt %s -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
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)
9 define void @test_eq_eq(i32 %a, i32 %b) {
10 %cmp1 = icmp eq i32 %a, %b
11 br i1 %cmp1, label %untaken, label %taken
14 %cmp2 = icmp eq i32 %a, %b
15 br i1 %cmp2, label %istrue, label %isfalse
18 call void @is(i1 true)
22 call void @is(i1 false)
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)
33 define void @test_eq_ne(i32 %a, i32 %b) {
34 %cmp1 = icmp eq i32 %a, %b
35 br i1 %cmp1, label %untaken, label %taken
38 %cmp2 = icmp ne i32 %a, %b
39 br i1 %cmp2, label %istrue, label %isfalse
42 call void @is(i1 true)
46 call void @is(i1 false)
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)
57 define void @test_ne_ne(i32 %a, i32 %b) {
58 %cmp1 = icmp ne i32 %a, %b
59 br i1 %cmp1, label %untaken, label %taken
62 %cmp2 = icmp ne i32 %a, %b
63 br i1 %cmp2, label %istrue, label %isfalse
66 call void @is(i1 true)
70 call void @is(i1 false)
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)
81 define void @test_ne_ugt(i32 %a, i32 %b) {
82 %cmp1 = icmp ne i32 %a, %b
83 br i1 %cmp1, label %untaken, label %taken
86 %cmp2 = icmp ugt i32 %a, %b
87 br i1 %cmp2, label %istrue, label %isfalse
90 call void @is(i1 true)
94 call void @is(i1 false)
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)
105 define void @test_ne_uge(i32 %a, i32 %b) {
106 %cmp1 = icmp ne i32 %a, %b
107 br i1 %cmp1, label %untaken, label %taken
110 %cmp2 = icmp uge i32 %a, %b
111 br i1 %cmp2, label %istrue, label %isfalse
114 call void @is(i1 true)
118 call void @is(i1 false)
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)
129 define void @test_ne_ult(i32 %a, i32 %b) {
130 %cmp1 = icmp ne i32 %a, %b
131 br i1 %cmp1, label %untaken, label %taken
134 %cmp2 = icmp ult i32 %a, %b
135 br i1 %cmp2, label %istrue, label %isfalse
138 call void @is(i1 true)
142 call void @is(i1 false)
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)
153 define void @test_ne_ule(i32 %a, i32 %b) {
154 %cmp1 = icmp ne i32 %a, %b
155 br i1 %cmp1, label %untaken, label %taken
158 %cmp2 = icmp ule i32 %a, %b
159 br i1 %cmp2, label %istrue, label %isfalse
162 call void @is(i1 true)
166 call void @is(i1 false)
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)
177 define void @test_ugt_ugt(i32 %a, i32 %b) {
178 %cmp1 = icmp ugt i32 %a, %b
179 br i1 %cmp1, label %untaken, label %taken
182 %cmp2 = icmp ugt i32 %a, %b
183 br i1 %cmp2, label %istrue, label %isfalse
186 call void @is(i1 true)
190 call void @is(i1 false)
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)
201 define void @test_ugt_ule(i32 %a, i32 %b) {
202 %cmp1 = icmp ugt i32 %a, %b
203 br i1 %cmp1, label %untaken, label %taken
206 %cmp2 = icmp ule i32 %a, %b
207 br i1 %cmp2, label %istrue, label %isfalse
210 call void @is(i1 true)
214 call void @is(i1 false)
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)
225 define void @test_uge_uge(i32 %a, i32 %b) {
226 %cmp1 = icmp uge i32 %a, %b
227 br i1 %cmp1, label %untaken, label %taken
230 %cmp2 = icmp uge i32 %a, %b
231 br i1 %cmp2, label %istrue, label %isfalse
234 call void @is(i1 true)
238 call void @is(i1 false)
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)
249 define void @test_uge_ult(i32 %a, i32 %b) {
250 %cmp1 = icmp uge i32 %a, %b
251 br i1 %cmp1, label %untaken, label %taken
254 %cmp2 = icmp ult i32 %a, %b
255 br i1 %cmp2, label %istrue, label %isfalse
258 call void @is(i1 true)
262 call void @is(i1 false)
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)
273 define void @test_uge_ule(i32 %a, i32 %b) {
274 %cmp1 = icmp uge i32 %a, %b
275 br i1 %cmp1, label %untaken, label %taken
278 %cmp2 = icmp ule i32 %a, %b
279 br i1 %cmp2, label %istrue, label %isfalse
282 call void @is(i1 true)
286 call void @is(i1 false)
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)
297 define void @test_ult_ult(i32 %a, i32 %b) {
298 %cmp1 = icmp ult i32 %a, %b
299 br i1 %cmp1, label %untaken, label %taken
302 %cmp2 = icmp ult i32 %a, %b
303 br i1 %cmp2, label %istrue, label %isfalse
306 call void @is(i1 true)
310 call void @is(i1 false)
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)
321 define void @test_ule_ule(i32 %a, i32 %b) {
322 %cmp1 = icmp ule i32 %a, %b
323 br i1 %cmp1, label %untaken, label %taken
326 %cmp2 = icmp ule i32 %a, %b
327 br i1 %cmp2, label %istrue, label %isfalse
330 call void @is(i1 true)
334 call void @is(i1 false)