1 ; RUN: opt < %s -ipsccp -S | FileCheck %s
2 ; RUN: opt < %s -enable-debugify -ipsccp -debugify-quiet -disable-output
4 ;;======================== test1
6 define internal i32 @test1a(i32 %A) {
10 ; CHECK-LABEL: define internal i32 @test1a(
11 ; CHECK: ret i32 undef
13 define i32 @test1b() {
14 %X = call i32 @test1a( i32 17 )
17 ; CHECK-LABEL: define i32 @test1b(
23 ;;======================== test2
25 define internal i32 @test2a(i32 %A) {
26 %C = icmp eq i32 %A, 0
27 br i1 %C, label %T, label %F
29 %B = call i32 @test2a( i32 0 )
32 %C.upgrd.1 = call i32 @test2a(i32 1)
35 ; CHECK-LABEL: define internal i32 @test2a(
36 ; CHECK-NEXT: br label %T
37 ; CHECK: ret i32 undef
40 define i32 @test2b() {
41 %X = call i32 @test2a(i32 0)
44 ; CHECK-LABEL: define i32 @test2b(
45 ; CHECK-NEXT: %X = call i32 @test2a(i32 0)
46 ; CHECK-NEXT: ret i32 0
49 ;;======================== test3
51 @G = internal global i32 undef
53 define void @test3a() {
54 %X = load i32, i32* @G
58 ; CHECK-LABEL: define void @test3a(
59 ; CHECK-NEXT: ret void
62 define i32 @test3b() {
63 %V = load i32, i32* @G
64 %C = icmp eq i32 %V, 17
65 br i1 %C, label %T, label %F
70 store i32 123, i32* @G
73 ; CHECK-LABEL: define i32 @test3b(
78 ;;======================== test4
80 define internal {i64,i64} @test4a() {
81 %a = insertvalue {i64,i64} undef, i64 4, 1
82 %b = insertvalue {i64,i64} %a, i64 5, 0
86 ; CHECK-LABEL: define internal { i64, i64 } @test4a(
87 ; CHECK-NEXT: ret { i64, i64 } undef
90 define i64 @test4b() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
91 %a = invoke {i64,i64} @test4a()
92 to label %A unwind label %B
94 %b = extractvalue {i64,i64} %a, 0
95 %c = call i64 @test4c(i64 %b)
98 %val = landingpad { i8*, i32 }
102 ; CHECK: define i64 @test4b()
103 ; CHECK: %c = call i64 @test4c(i64 5)
104 ; CHECK-NEXT: ret i64 5
107 define internal i64 @test4c(i64 %a) {
110 ; CHECK-LABEL: define internal i64 @test4c(
111 ; CHECK: ret i64 undef
115 ;;======================== test5
118 define internal {i64,i64} @test5a() {
119 %a = insertvalue {i64,i64} undef, i64 4, 1
120 %b = insertvalue {i64,i64} %a, i64 5, 0
124 define i64 @test5b() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
125 %a = invoke {i64,i64} @test5a()
126 to label %A unwind label %B
128 %c = call i64 @test5c({i64,i64} %a)
131 %val = landingpad { i8*, i32 }
136 ; CHECK: define i64 @test5b()
138 ; CHECK-NEXT: %c = call i64 @test5c({ i64, i64 } { i64 5, i64 4 })
139 ; CHECK-NEXT: ret i64 5
141 define internal i64 @test5c({i64,i64} %a) {
142 %b = extractvalue {i64,i64} %a, 0
147 ;;======================== test6
149 define i64 @test6a() {
153 define i64 @test6b() {
154 %a = call i64 @test6a()
157 ; CHECK-LABEL: define i64 @test6b(
160 ;;======================== test7
165 define internal %T @test7a(i32 %A) {
167 %mrv0 = insertvalue %T undef, i32 %X, 0
168 %mrv1 = insertvalue %T %mrv0, i32 %A, 1
170 ; CHECK-LABEL: @test7a(
171 ; CHECK-NEXT: ret %T undef
174 define i32 @test7b() {
175 %X = call %T @test7a(i32 17)
176 %Y = extractvalue %T %X, 0
179 ; CHECK-LABEL: define i32 @test7b(
180 ; CHECK-NEXT: call %T @test7a(i32 17)
181 ; CHECK-NEXT: ret i32 36
184 ;;======================== test8
187 define internal {} @test8a(i32 %A, i32* %P) {
188 store i32 %A, i32* %P
190 ; CHECK-LABEL: @test8a(
191 ; CHECK-NEXT: store i32 5,
195 define void @test8b(i32* %P) {
196 %X = call {} @test8a(i32 5, i32* %P)
198 ; CHECK-LABEL: define void @test8b(
199 ; CHECK-NEXT: call {} @test8a
200 ; CHECK-NEXT: ret void
203 ;;======================== test9
205 @test9g = internal global { } zeroinitializer
207 define void @test9() {
209 %local_foo = alloca { }
210 load { }, { }* @test9g
211 store { } %0, { }* %local_foo
215 ; CHECK-LABEL: define void @test9(
217 ; CHECK-NEXT: %local_foo = alloca {}
218 ; CHECK-NEXT: store {} zeroinitializer, {}* %local_foo
219 ; CHECK-NEXT: ret void
221 declare i32 @__gxx_personality_v0(...)
223 ;;======================== test10
225 define i32 @test10a() nounwind {
227 %call = call i32 @test10b(i32 undef)
229 ; CHECK-LABEL: define i32 @test10a(
233 define internal i32 @test10b(i32 %x) nounwind {
237 ; CHECK-LABEL: define internal i32 @test10b(
238 ; CHECK: ret i32 undef
241 ;;======================== test11
243 define i64 @test11a() {
244 %xor = xor i64 undef, undef
246 ; CHECK-LABEL: define i64 @test11a
250 define i64 @test11b() {
251 %call1 = call i64 @test11a()
252 %call2 = call i64 @llvm.ctpop.i64(i64 %call1)
254 ; CHECK-LABEL: define i64 @test11b
255 ; CHECK: %[[call1:.*]] = call i64 @test11a()
256 ; CHECK-NOT: call i64 @llvm.ctpop.i64
257 ; CHECK-NEXT: ret i64 0
260 declare i64 @llvm.ctpop.i64(i64)
262 ;;======================== test12
263 ;; Ensure that a struct as an arg to a potentially constant-foldable
264 ;; function does not crash SCCP (for now it'll just ignores it)
266 define i1 @test12() {
267 %c = call i1 @llvm.is.constant.sl_i32i32s({i32, i32} {i32 -1, i32 32})
269 ; CHECK-LABEL: define i1 @test12
273 declare i1 @llvm.is.constant.sl_i32i32s({i32, i32} %a)