1 ; Test that -disable-simplify-libcalls is wired up correctly.
3 ; RUN: opt < %s -instcombine -disable-simplify-libcalls -S | FileCheck %s
4 ; RUN: opt < %s -passes=instcombine -disable-simplify-libcalls -S | FileCheck %s
6 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"
8 @.str = constant [1 x i8] zeroinitializer, align 1
9 @.str1 = constant [13 x i8] c"hello, world\00", align 1
10 @.str2 = constant [4 x i8] c"foo\00", align 1
11 @.str3 = constant [4 x i8] c"bar\00", align 1
12 @.str4 = constant [6 x i8] c"123.4\00", align 1
13 @.str5 = constant [5 x i8] c"1234\00", align 1
14 @empty = constant [1 x i8] c"\00", align 1
16 declare double @ceil(double)
17 declare double @copysign(double, double)
18 declare double @cos(double)
19 declare double @fabs(double)
20 declare double @floor(double)
21 declare i8* @strcat(i8*, i8*)
22 declare i8* @strncat(i8*, i8*, i32)
23 declare i8* @strchr(i8*, i32)
24 declare i8* @strrchr(i8*, i32)
25 declare i32 @strcmp(i8*, i8*)
26 declare i32 @strncmp(i8*, i8*, i64)
27 declare i8* @strcpy(i8*, i8*)
28 declare i8* @stpcpy(i8*, i8*)
29 declare i8* @strncpy(i8*, i8*, i64)
30 declare i64 @strlen(i8*)
31 declare i8* @strpbrk(i8*, i8*)
32 declare i64 @strspn(i8*, i8*)
33 declare double @strtod(i8*, i8**)
34 declare float @strtof(i8*, i8**)
35 declare x86_fp80 @strtold(i8*, i8**)
36 declare i64 @strtol(i8*, i8**, i32)
37 declare i64 @strtoll(i8*, i8**, i32)
38 declare i64 @strtoul(i8*, i8**, i32)
39 declare i64 @strtoull(i8*, i8**, i32)
40 declare i64 @strcspn(i8*, i8*)
43 declare i32 @ffsl(i64)
44 declare i32 @ffsll(i64)
45 declare i32 @fprintf(i8*, i8*)
46 declare i32 @isascii(i32)
47 declare i32 @isdigit(i32)
48 declare i32 @toascii(i32)
49 declare i64 @labs(i64)
50 declare i64 @llabs(i64)
51 declare i32 @printf(i8*)
52 declare i32 @sprintf(i8*, i8*)
54 define double @t1(double %x) {
56 %ret = call double @ceil(double %x)
58 ; CHECK: call double @ceil
61 define double @t2(double %x, double %y) {
63 %ret = call double @copysign(double %x, double %y)
65 ; CHECK: call double @copysign
68 define double @t3(double %x) {
70 %call = call double @cos(double %x)
72 ; CHECK: call double @cos
75 define double @t4(double %x) {
77 %ret = call double @fabs(double %x)
79 ; CHECK: call double @fabs
82 define double @t5(double %x) {
84 %ret = call double @floor(double %x)
86 ; CHECK: call double @floor
89 define i8* @t6(i8* %x) {
91 %empty = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
92 %ret = call i8* @strcat(i8* %x, i8* %empty)
94 ; CHECK: call i8* @strcat
97 define i8* @t7(i8* %x) {
99 %empty = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
100 %ret = call i8* @strncat(i8* %x, i8* %empty, i32 1)
102 ; CHECK: call i8* @strncat
107 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
108 %ret = call i8* @strchr(i8* %x, i32 119)
110 ; CHECK: call i8* @strchr
115 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
116 %ret = call i8* @strrchr(i8* %x, i32 119)
118 ; CHECK: call i8* @strrchr
123 %x = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
124 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str3, i32 0, i32 0
125 %ret = call i32 @strcmp(i8* %x, i8* %y)
127 ; CHECK: call i32 @strcmp
132 %x = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
133 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str3, i32 0, i32 0
134 %ret = call i32 @strncmp(i8* %x, i8* %y, i64 3)
136 ; CHECK: call i32 @strncmp
139 define i8* @t12(i8* %x) {
141 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
142 %ret = call i8* @strcpy(i8* %x, i8* %y)
144 ; CHECK: call i8* @strcpy
147 define i8* @t13(i8* %x) {
149 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
150 %ret = call i8* @stpcpy(i8* %x, i8* %y)
152 ; CHECK: call i8* @stpcpy
155 define i8* @t14(i8* %x) {
157 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
158 %ret = call i8* @strncpy(i8* %x, i8* %y, i64 3)
160 ; CHECK: call i8* @strncpy
165 %x = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
166 %ret = call i64 @strlen(i8* %x)
168 ; CHECK: call i64 @strlen
171 define i8* @t16(i8* %x) {
173 %y = getelementptr inbounds [1 x i8], [1 x i8]* @.str, i32 0, i32 0
174 %ret = call i8* @strpbrk(i8* %x, i8* %y)
176 ; CHECK: call i8* @strpbrk
179 define i64 @t17(i8* %x) {
181 %y = getelementptr inbounds [1 x i8], [1 x i8]* @.str, i32 0, i32 0
182 %ret = call i64 @strspn(i8* %x, i8* %y)
184 ; CHECK: call i64 @strspn
187 define double @t18(i8** %y) {
189 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0
190 %ret = call double @strtod(i8* %x, i8** %y)
192 ; CHECK: call double @strtod
195 define float @t19(i8** %y) {
197 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0
198 %ret = call float @strtof(i8* %x, i8** %y)
200 ; CHECK: call float @strtof
203 define x86_fp80 @t20(i8** %y) {
205 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0
206 %ret = call x86_fp80 @strtold(i8* %x, i8** %y)
208 ; CHECK: call x86_fp80 @strtold
211 define i64 @t21(i8** %y) {
213 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
214 %ret = call i64 @strtol(i8* %x, i8** %y, i32 10)
216 ; CHECK: call i64 @strtol
219 define i64 @t22(i8** %y) {
221 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
222 %ret = call i64 @strtoll(i8* %x, i8** %y, i32 10)
224 ; CHECK: call i64 @strtoll
227 define i64 @t23(i8** %y) {
229 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
230 %ret = call i64 @strtoul(i8* %x, i8** %y, i32 10)
232 ; CHECK: call i64 @strtoul
235 define i64 @t24(i8** %y) {
237 %x = getelementptr inbounds [5 x i8], [5 x i8]* @.str5, i64 0, i64 0
238 %ret = call i64 @strtoull(i8* %x, i8** %y, i32 10)
240 ; CHECK: call i64 @strtoull
243 define i64 @t25(i8* %y) {
245 %x = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
246 %ret = call i64 @strcspn(i8* %x, i8* %y)
248 ; CHECK: call i64 @strcspn
251 define i32 @t26(i32 %y) {
253 %ret = call i32 @abs(i32 %y)
255 ; CHECK: call i32 @abs
258 define i32 @t27(i32 %y) {
260 %ret = call i32 @ffs(i32 %y)
262 ; CHECK: call i32 @ffs
265 define i32 @t28(i64 %y) {
267 %ret = call i32 @ffsl(i64 %y)
269 ; CHECK: call i32 @ffsl
272 define i32 @t29(i64 %y) {
274 %ret = call i32 @ffsll(i64 %y)
276 ; CHECK: call i32 @ffsll
281 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
282 call i32 @fprintf(i8* null, i8* %x)
284 ; CHECK: call i32 @fprintf
287 define i32 @t31(i32 %y) {
289 %ret = call i32 @isascii(i32 %y)
291 ; CHECK: call i32 @isascii
294 define i32 @t32(i32 %y) {
296 %ret = call i32 @isdigit(i32 %y)
298 ; CHECK: call i32 @isdigit
301 define i32 @t33(i32 %y) {
303 %ret = call i32 @toascii(i32 %y)
305 ; CHECK: call i32 @toascii
308 define i64 @t34(i64 %y) {
310 %ret = call i64 @labs(i64 %y)
312 ; CHECK: call i64 @labs
315 define i64 @t35(i64 %y) {
317 %ret = call i64 @llabs(i64 %y)
319 ; CHECK: call i64 @llabs
324 %x = getelementptr inbounds [1 x i8], [1 x i8]* @empty, i32 0, i32 0
325 call i32 @printf(i8* %x)
327 ; CHECK: call i32 @printf
330 define void @t37(i8* %x) {
332 %y = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0
333 call i32 @sprintf(i8* %x, i8* %y)
335 ; CHECK: call i32 @sprintf