1 ; Test that -disable-simplify-libcalls is wired up correctly.
3 ; RUN: opt < %s -instcombine -disable-simplify-libcalls -S | FileCheck %s
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7 @.str = constant [1 x i8] zeroinitializer, align 1
8 @.str1 = constant [13 x i8] c"hello, world\00", align 1
9 @.str2 = constant [4 x i8] c"foo\00", align 1
10 @.str3 = constant [4 x i8] c"bar\00", align 1
11 @.str4 = constant [6 x i8] c"123.4\00", align 1
12 @.str5 = constant [5 x i8] c"1234\00", align 1
13 @empty = constant [1 x i8] c"\00", align 1
15 declare double @ceil(double)
16 declare double @copysign(double, double)
17 declare double @cos(double)
18 declare double @fabs(double)
19 declare double @floor(double)
20 declare i8* @strcat(i8*, i8*)
21 declare i8* @strncat(i8*, i8*, i32)
22 declare i8* @strchr(i8*, i32)
23 declare i8* @strrchr(i8*, i32)
24 declare i32 @strcmp(i8*, i8*)
25 declare i32 @strncmp(i8*, i8*, i64)
26 declare i8* @strcpy(i8*, i8*)
27 declare i8* @stpcpy(i8*, i8*)
28 declare i8* @strncpy(i8*, i8*, i64)
29 declare i64 @strlen(i8*)
30 declare i8* @strpbrk(i8*, i8*)
31 declare i64 @strspn(i8*, i8*)
32 declare double @strtod(i8*, i8**)
33 declare float @strtof(i8*, i8**)
34 declare x86_fp80 @strtold(i8*, i8**)
35 declare i64 @strtol(i8*, i8**, i32)
36 declare i64 @strtoll(i8*, i8**, i32)
37 declare i64 @strtoul(i8*, i8**, i32)
38 declare i64 @strtoull(i8*, i8**, i32)
39 declare i64 @strcspn(i8*, i8*)
42 declare i32 @ffsl(i64)
43 declare i32 @ffsll(i64)
44 declare i32 @fprintf(i8*, i8*)
45 declare i32 @isascii(i32)
46 declare i32 @isdigit(i32)
47 declare i32 @toascii(i32)
48 declare i64 @labs(i64)
49 declare i64 @llabs(i64)
50 declare i32 @printf(i8*)
51 declare i32 @sprintf(i8*, i8*)
53 define double @t1(double %x) {
55 %ret = call double @ceil(double %x)
57 ; CHECK: call double @ceil
60 define double @t2(double %x, double %y) {
62 %ret = call double @copysign(double %x, double %y)
64 ; CHECK: call double @copysign
67 define double @t3(double %x) {
69 %call = call double @cos(double %x)
71 ; CHECK: call double @cos
74 define double @t4(double %x) {
76 %ret = call double @fabs(double %x)
78 ; CHECK: call double @fabs
81 define double @t5(double %x) {
83 %ret = call double @floor(double %x)
85 ; CHECK: call double @floor
88 define i8* @t6(i8* %x) {
90 %empty = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
91 %ret = call i8* @strcat(i8* %x, i8* %empty)
93 ; CHECK: call i8* @strcat
96 define i8* @t7(i8* %x) {
98 %empty = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
99 %ret = call i8* @strncat(i8* %x, i8* %empty, i32 1)
101 ; CHECK: call i8* @strncat
106 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
107 %ret = call i8* @strchr(i8* %x, i32 119)
109 ; CHECK: call i8* @strchr
114 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
115 %ret = call i8* @strrchr(i8* %x, i32 119)
117 ; CHECK: call i8* @strrchr
122 %x = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
123 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str3, i32 0, i32 0
124 %ret = call i32 @strcmp(i8* %x, i8* %y)
126 ; CHECK: call i32 @strcmp
131 %x = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
132 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str3, i32 0, i32 0
133 %ret = call i32 @strncmp(i8* %x, i8* %y, i64 3)
135 ; CHECK: call i32 @strncmp
138 define i8* @t12(i8* %x) {
140 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
141 %ret = call i8* @strcpy(i8* %x, i8* %y)
143 ; CHECK: call i8* @strcpy
146 define i8* @t13(i8* %x) {
148 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
149 %ret = call i8* @stpcpy(i8* %x, i8* %y)
151 ; CHECK: call i8* @stpcpy
154 define i8* @t14(i8* %x) {
156 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
157 %ret = call i8* @strncpy(i8* %x, i8* %y, i64 3)
159 ; CHECK: call i8* @strncpy
164 %x = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
165 %ret = call i64 @strlen(i8* %x)
167 ; CHECK: call i64 @strlen
170 define i8* @t16(i8* %x) {
172 %y = getelementptr inbounds [1 x i8], [1 x i8]* @.str, i32 0, i32 0
173 %ret = call i8* @strpbrk(i8* %x, i8* %y)
175 ; CHECK: call i8* @strpbrk
178 define i64 @t17(i8* %x) {
180 %y = getelementptr inbounds [1 x i8], [1 x i8]* @.str, i32 0, i32 0
181 %ret = call i64 @strspn(i8* %x, i8* %y)
183 ; CHECK: call i64 @strspn
186 define double @t18(i8** %y) {
188 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0
189 %ret = call double @strtod(i8* %x, i8** %y)
191 ; CHECK: call double @strtod
194 define float @t19(i8** %y) {
196 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0
197 %ret = call float @strtof(i8* %x, i8** %y)
199 ; CHECK: call float @strtof
202 define x86_fp80 @t20(i8** %y) {
204 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0
205 %ret = call x86_fp80 @strtold(i8* %x, i8** %y)
207 ; CHECK: call x86_fp80 @strtold
210 define i64 @t21(i8** %y) {
212 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
213 %ret = call i64 @strtol(i8* %x, i8** %y, i32 10)
215 ; CHECK: call i64 @strtol
218 define i64 @t22(i8** %y) {
220 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
221 %ret = call i64 @strtoll(i8* %x, i8** %y, i32 10)
223 ; CHECK: call i64 @strtoll
226 define i64 @t23(i8** %y) {
228 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
229 %ret = call i64 @strtoul(i8* %x, i8** %y, i32 10)
231 ; CHECK: call i64 @strtoul
234 define i64 @t24(i8** %y) {
236 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
237 %ret = call i64 @strtoull(i8* %x, i8** %y, i32 10)
239 ; CHECK: call i64 @strtoull
242 define i64 @t25(i8* %y) {
244 %x = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
245 %ret = call i64 @strcspn(i8* %x, i8* %y)
247 ; CHECK: call i64 @strcspn
250 define i32 @t26(i32 %y) {
252 %ret = call i32 @abs(i32 %y)
254 ; CHECK: call i32 @abs
257 define i32 @t27(i32 %y) {
259 %ret = call i32 @ffs(i32 %y)
261 ; CHECK: call i32 @ffs
264 define i32 @t28(i64 %y) {
266 %ret = call i32 @ffsl(i64 %y)
268 ; CHECK: call i32 @ffsl
271 define i32 @t29(i64 %y) {
273 %ret = call i32 @ffsll(i64 %y)
275 ; CHECK: call i32 @ffsll
280 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
281 call i32 @fprintf(i8* null, i8* %x)
283 ; CHECK: call i32 @fprintf
286 define i32 @t31(i32 %y) {
288 %ret = call i32 @isascii(i32 %y)
290 ; CHECK: call i32 @isascii
293 define i32 @t32(i32 %y) {
295 %ret = call i32 @isdigit(i32 %y)
297 ; CHECK: call i32 @isdigit
300 define i32 @t33(i32 %y) {
302 %ret = call i32 @toascii(i32 %y)
304 ; CHECK: call i32 @toascii
307 define i64 @t34(i64 %y) {
309 %ret = call i64 @labs(i64 %y)
311 ; CHECK: call i64 @labs
314 define i64 @t35(i64 %y) {
316 %ret = call i64 @llabs(i64 %y)
318 ; CHECK: call i64 @llabs
323 %x = getelementptr inbounds [1 x i8], [1 x i8]* @empty, i32 0, i32 0
324 call i32 @printf(i8* %x)
326 ; CHECK: call i32 @printf
329 define void @t37(i8* %x) {
331 %y = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
332 call i32 @sprintf(i8* %x, i8* %y)
334 ; CHECK: call i32 @sprintf