1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
3 ; RUN: opt < %s -enable-debugify -passes=ipsccp -debugify-quiet -disable-output
4 ; RUN: opt < %s -enable-debugify -passes=ipsccp -debugify-quiet -disable-output --try-experimental-debuginfo-iterators
6 ;;======================== test1
8 define internal i32 @test1a(i32 %A) {
9 ; CHECK-LABEL: define internal i32 @test1a
10 ; CHECK-SAME: (i32 [[A:%.*]]) {
11 ; CHECK-NEXT: ret i32 poison
17 define i32 @test1b() {
18 ; CHECK-LABEL: define i32 @test1b() {
19 ; CHECK-NEXT: [[X:%.*]] = call i32 @test1a(i32 17)
20 ; CHECK-NEXT: ret i32 17
22 %X = call i32 @test1a( i32 17 )
29 ;;======================== test2
31 define internal i32 @test2a(i32 %A) {
32 ; CHECK-LABEL: define internal i32 @test2a
33 ; CHECK-SAME: (i32 [[A:%.*]]) {
34 ; CHECK-NEXT: br label [[T:%.*]]
36 ; CHECK-NEXT: [[B:%.*]] = call i32 @test2a(i32 0)
37 ; CHECK-NEXT: ret i32 poison
39 %C = icmp eq i32 %A, 0
40 br i1 %C, label %T, label %F
42 %B = call i32 @test2a( i32 0 )
45 %C.upgrd.1 = call i32 @test2a(i32 1)
49 define i32 @test2b() {
50 ; CHECK-LABEL: define i32 @test2b() {
51 ; CHECK-NEXT: [[X:%.*]] = call i32 @test2a(i32 0)
52 ; CHECK-NEXT: ret i32 0
54 %X = call i32 @test2a(i32 0)
58 ;;======================== test3
60 @G = internal global i32 undef
62 define void @test3a() {
63 ; CHECK-LABEL: define void @test3a() {
64 ; CHECK-NEXT: [[X:%.*]] = load i32, ptr @G, align 4
65 ; CHECK-NEXT: store i32 [[X]], ptr @G, align 4
66 ; CHECK-NEXT: ret void
73 define i32 @test3b() {
74 ; CHECK-LABEL: define range(i32 0, 18) i32 @test3b() {
75 ; CHECK-NEXT: [[V:%.*]] = load i32, ptr @G, align 4
76 ; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[V]], 17
77 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
79 ; CHECK-NEXT: store i32 17, ptr @G, align 4
80 ; CHECK-NEXT: ret i32 17
82 ; CHECK-NEXT: store i32 123, ptr @G, align 4
83 ; CHECK-NEXT: ret i32 0
86 %C = icmp eq i32 %V, 17
87 br i1 %C, label %T, label %F
96 ;;======================== test4
98 define internal {i64,i64} @test4a() {
99 ; CHECK-LABEL: define internal { i64, i64 } @test4a() {
100 ; CHECK-NEXT: ret { i64, i64 } poison
102 %a = insertvalue {i64,i64} undef, i64 4, 1
103 %b = insertvalue {i64,i64} %a, i64 5, 0
107 define i64 @test4b() personality ptr @__gxx_personality_v0 {
108 ; CHECK-LABEL: define range(i64 0, 6) i64 @test4b() personality ptr @__gxx_personality_v0 {
109 ; CHECK-NEXT: [[A:%.*]] = invoke { i64, i64 } @test4a()
110 ; CHECK-NEXT: to label [[A:%.*]] unwind label [[B:%.*]]
112 ; CHECK-NEXT: [[C:%.*]] = call i64 @test4c(i64 5)
113 ; CHECK-NEXT: ret i64 5
115 ; CHECK-NEXT: [[VAL:%.*]] = landingpad { ptr, i32 }
116 ; CHECK-NEXT: catch ptr null
117 ; CHECK-NEXT: ret i64 0
119 %a = invoke {i64,i64} @test4a()
120 to label %A unwind label %B
122 %b = extractvalue {i64,i64} %a, 0
123 %c = call i64 @test4c(i64 %b)
126 %val = landingpad { ptr, i32 }
131 define internal i64 @test4c(i64 %a) {
132 ; CHECK-LABEL: define internal i64 @test4c
133 ; CHECK-SAME: (i64 [[A:%.*]]) {
134 ; CHECK-NEXT: ret i64 poison
139 ;;======================== test5
142 define internal {i64,i64} @test5a() {
143 ; CHECK-LABEL: define internal { i64, i64 } @test5a() {
144 ; CHECK-NEXT: ret { i64, i64 } poison
146 %a = insertvalue {i64,i64} undef, i64 4, 1
147 %b = insertvalue {i64,i64} %a, i64 5, 0
151 define i64 @test5b() personality ptr @__gxx_personality_v0 {
152 ; CHECK-LABEL: define range(i64 0, 6) i64 @test5b() personality ptr @__gxx_personality_v0 {
153 ; CHECK-NEXT: [[A:%.*]] = invoke { i64, i64 } @test5a()
154 ; CHECK-NEXT: to label [[A:%.*]] unwind label [[B:%.*]]
156 ; CHECK-NEXT: [[C:%.*]] = call i64 @test5c({ i64, i64 } { i64 5, i64 4 })
157 ; CHECK-NEXT: ret i64 5
159 ; CHECK-NEXT: [[VAL:%.*]] = landingpad { ptr, i32 }
160 ; CHECK-NEXT: catch ptr null
161 ; CHECK-NEXT: ret i64 0
163 %a = invoke {i64,i64} @test5a()
164 to label %A unwind label %B
166 %c = call i64 @test5c({i64,i64} %a)
169 %val = landingpad { ptr, i32 }
174 define internal i64 @test5c({i64,i64} %a) {
175 ; CHECK-LABEL: define internal i64 @test5c
176 ; CHECK-SAME: ({ i64, i64 } [[A:%.*]]) {
177 ; CHECK-NEXT: ret i64 poison
179 %b = extractvalue {i64,i64} %a, 0
184 ;;======================== test6
186 define i64 @test6a() {
187 ; CHECK-LABEL: define i64 @test6a() {
188 ; CHECK-NEXT: ret i64 0
193 define i64 @test6b() {
194 ; CHECK-LABEL: define i64 @test6b() {
195 ; CHECK-NEXT: [[A:%.*]] = call i64 @test6a()
196 ; CHECK-NEXT: ret i64 0
198 %a = call i64 @test6a()
202 ;;======================== test7
206 define internal %T @test7a(i32 %A) {
207 ; CHECK-LABEL: define internal %T @test7a
208 ; CHECK-SAME: (i32 [[A:%.*]]) {
209 ; CHECK-NEXT: ret [[T:%.*]] poison
212 %mrv0 = insertvalue %T undef, i32 %X, 0
213 %mrv1 = insertvalue %T %mrv0, i32 %A, 1
217 define i32 @test7b() {
218 ; CHECK-LABEL: define i32 @test7b() {
219 ; CHECK-NEXT: [[X:%.*]] = call [[T:%.*]] @[[TEST7A:[a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*]](i32 17)
220 ; CHECK-NEXT: ret i32 36
222 %X = call %T @test7a(i32 17)
223 %Y = extractvalue %T %X, 0
228 ;;======================== test8
231 define internal {} @test8a(i32 %A, ptr %P) {
232 ; CHECK-LABEL: define internal {} @test8a
233 ; CHECK-SAME: (i32 [[A:%.*]], ptr [[P:%.*]]) {
234 ; CHECK-NEXT: store i32 5, ptr [[P]], align 4
235 ; CHECK-NEXT: ret {} poison
241 define void @test8b(ptr %P) {
242 ; CHECK-LABEL: define void @test8b
243 ; CHECK-SAME: (ptr [[P:%.*]]) {
244 ; CHECK-NEXT: [[X:%.*]] = call {} @test8a(i32 5, ptr [[P]])
245 ; CHECK-NEXT: ret void
247 %X = call {} @test8a(i32 5, ptr %P)
251 ;;======================== test9
253 @test9g = internal global { } zeroinitializer
255 define void @test9() {
256 ; CHECK-LABEL: define void @test9() {
258 ; CHECK-NEXT: [[LOCAL_FOO:%.*]] = alloca {}, align 8
259 ; CHECK-NEXT: store {} zeroinitializer, ptr [[LOCAL_FOO]], align 1
260 ; CHECK-NEXT: ret void
263 %local_foo = alloca { }
264 load { }, ptr @test9g
265 store { } %0, ptr %local_foo
269 declare i32 @__gxx_personality_v0(...)
271 ;;======================== test10
273 define i32 @test10a() nounwind {
274 ; CHECK-LABEL: define i32 @test10a
275 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
277 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @test10b(i32 undef)
278 ; CHECK-NEXT: ret i32 [[CALL]]
281 %call = call i32 @test10b(i32 undef)
286 define internal i32 @test10b(i32 %x) nounwind {
287 ; CHECK-LABEL: define internal i32 @test10b
288 ; CHECK-SAME: (i32 [[X:%.*]]) #[[ATTR0]] {
290 ; CHECK-NEXT: [[R:%.*]] = and i32 undef, 1
291 ; CHECK-NEXT: ret i32 [[R]]
298 ;;======================== test11
300 define i64 @test11a() {
301 ; CHECK-LABEL: define i64 @test11a() {
302 ; CHECK-NEXT: [[XOR:%.*]] = xor i64 undef, undef
303 ; CHECK-NEXT: ret i64 [[XOR]]
305 %xor = xor i64 undef, undef
309 define i64 @test11b() {
310 ; CHECK-LABEL: define i64 @test11b() {
311 ; CHECK-NEXT: [[CALL1:%.*]] = call i64 @test11a()
312 ; CHECK-NEXT: [[CALL2:%.*]] = call i64 @llvm.ctpop.i64(i64 [[CALL1]])
313 ; CHECK-NEXT: ret i64 [[CALL2]]
315 %call1 = call i64 @test11a()
316 %call2 = call i64 @llvm.ctpop.i64(i64 %call1)
320 declare i64 @llvm.ctpop.i64(i64)
322 ;;======================== test12
323 ;; Ensure that a struct as an arg to a potentially constant-foldable
324 ;; function does not crash SCCP (for now it'll just ignores it)
326 define i1 @test12() {
327 ; CHECK-LABEL: define i1 @test12() {
328 ; CHECK-NEXT: [[C:%.*]] = call i1 @llvm.is.constant.sl_i32i32s({ i32, i32 } { i32 -1, i32 32 })
329 ; CHECK-NEXT: ret i1 [[C]]
331 %c = call i1 @llvm.is.constant.sl_i32i32s({i32, i32} {i32 -1, i32 32})
335 declare i1 @llvm.is.constant.sl_i32i32s({i32, i32} %a)