1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -newgvn -S | FileCheck %s
8 define void @test3(i32 %x, i32 %y) {
10 ; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
11 ; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
12 ; CHECK-NEXT: [[Z:%.*]] = and i1 [[XZ]], [[YZ]]
13 ; CHECK-NEXT: br i1 [[Z]], label [[BOTH_ZERO:%.*]], label [[NOPE:%.*]]
15 ; CHECK-NEXT: call void @foo(i1 true)
16 ; CHECK-NEXT: call void @foo(i1 true)
17 ; CHECK-NEXT: call void @bar(i32 0)
18 ; CHECK-NEXT: call void @bar(i32 0)
19 ; CHECK-NEXT: ret void
21 ; CHECK-NEXT: call void @foo(i1 false)
22 ; CHECK-NEXT: ret void
24 %xz = icmp eq i32 %x, 0
25 %yz = icmp eq i32 %y, 0
27 br i1 %z, label %both_zero, label %nope
29 call void @foo(i1 %xz)
30 call void @foo(i1 %yz)
31 call void @bar(i32 %x)
32 call void @bar(i32 %y)
38 define void @test4(i1 %b, i32 %x) {
39 ; CHECK-LABEL: @test4(
40 ; CHECK-NEXT: br i1 [[B:%.*]], label [[SW:%.*]], label [[CASE3:%.*]]
42 ; CHECK-NEXT: switch i32 [[X:%.*]], label [[DEFAULT:%.*]] [
43 ; CHECK-NEXT: i32 0, label [[CASE0:%.*]]
44 ; CHECK-NEXT: i32 1, label [[CASE1:%.*]]
45 ; CHECK-NEXT: i32 2, label [[CASE0]]
46 ; CHECK-NEXT: i32 3, label [[CASE3]]
47 ; CHECK-NEXT: i32 4, label [[DEFAULT]]
50 ; CHECK-NEXT: call void @bar(i32 [[X]])
51 ; CHECK-NEXT: ret void
53 ; CHECK-NEXT: call void @bar(i32 [[X]])
54 ; CHECK-NEXT: ret void
56 ; CHECK-NEXT: call void @bar(i32 1)
57 ; CHECK-NEXT: ret void
59 ; CHECK-NEXT: call void @bar(i32 [[X]])
60 ; CHECK-NEXT: ret void
62 br i1 %b, label %sw, label %case3
64 switch i32 %x, label %default [
72 call void @bar(i32 %x)
75 call void @bar(i32 %x)
78 call void @bar(i32 %x)
81 call void @bar(i32 %x)
85 define i1 @test5(i32 %x, i32 %y) {
86 ; CHECK-LABEL: @test5(
87 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
88 ; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
90 ; CHECK-NEXT: ret i1 false
92 ; CHECK-NEXT: ret i1 false
94 %cmp = icmp eq i32 %x, %y
95 br i1 %cmp, label %same, label %different
98 %cmp2 = icmp ne i32 %x, %y
102 %cmp3 = icmp eq i32 %x, %y
107 define i1 @test7(i32 %x, i32 %y) {
108 ; CHECK-LABEL: @test7(
109 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
110 ; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
112 ; CHECK-NEXT: ret i1 false
114 ; CHECK-NEXT: ret i1 false
116 %cmp = icmp sgt i32 %x, %y
117 br i1 %cmp, label %same, label %different
120 %cmp2 = icmp sle i32 %x, %y
124 %cmp3 = icmp sgt i32 %x, %y
128 define i1 @test7_fp(float %x, float %y) {
129 ; CHECK-LABEL: @test7_fp(
130 ; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
131 ; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
133 ; CHECK-NEXT: ret i1 false
135 ; CHECK-NEXT: ret i1 false
137 %cmp = fcmp ogt float %x, %y
138 br i1 %cmp, label %same, label %different
141 %cmp2 = fcmp ule float %x, %y
145 %cmp3 = fcmp ogt float %x, %y
150 define i32 @test9(i32 %i, i32 %j) {
151 ; CHECK-LABEL: @test9(
152 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], [[J:%.*]]
153 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[RET:%.*]]
155 ; CHECK-NEXT: ret i32 0
157 ; CHECK-NEXT: ret i32 5
159 %cmp = icmp eq i32 %i, %j
160 br i1 %cmp, label %cond_true, label %ret
163 %diff = sub i32 %i, %j
171 define i32 @test10(i32 %j, i32 %i) {
172 ; CHECK-LABEL: @test10(
173 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], [[J:%.*]]
174 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[RET:%.*]]
176 ; CHECK-NEXT: ret i32 0
178 ; CHECK-NEXT: ret i32 5
180 %cmp = icmp eq i32 %i, %j
181 br i1 %cmp, label %cond_true, label %ret
184 %diff = sub i32 %i, %j
191 declare i32 @yogibar()
193 define i32 @test11(i32 %x) {
194 ; CHECK-LABEL: @test11(
195 ; CHECK-NEXT: [[V0:%.*]] = call i32 @yogibar()
196 ; CHECK-NEXT: [[V1:%.*]] = call i32 @yogibar()
197 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[V0]], [[V1]]
198 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[NEXT:%.*]]
200 ; CHECK-NEXT: ret i32 [[V0]]
202 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[X:%.*]], [[V0]]
203 ; CHECK-NEXT: br i1 [[CMP2]], label [[COND_TRUE2:%.*]], label [[NEXT2:%.*]]
205 ; CHECK-NEXT: ret i32 [[X]]
207 ; CHECK-NEXT: ret i32 0
209 %v0 = call i32 @yogibar()
210 %v1 = call i32 @yogibar()
211 %cmp = icmp eq i32 %v0, %v1
212 br i1 %cmp, label %cond_true, label %next
218 %cmp2 = icmp eq i32 %x, %v0
219 br i1 %cmp2, label %cond_true2, label %next2
228 define i32 @test12(i32 %x) {
229 ; CHECK-LABEL: @test12(
230 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 0
231 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
233 ; CHECK-NEXT: br label [[RET:%.*]]
235 ; CHECK-NEXT: br label [[RET]]
237 ; CHECK-NEXT: [[RES:%.*]] = phi i32 [ 0, [[COND_TRUE]] ], [ [[X]], [[COND_FALSE]] ]
238 ; CHECK-NEXT: ret i32 [[RES]]
240 %cmp = icmp eq i32 %x, 0
241 br i1 %cmp, label %cond_true, label %cond_false
250 %res = phi i32 [ %x, %cond_true ], [ %x, %cond_false ]