1; Test that -disable-simplify-libcalls is wired up correctly. 2; 3; RUN: opt < %s -instcombine -disable-simplify-libcalls -S | FileCheck %s 4 5target 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" 6 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 14 15declare double @ceil(double) 16declare double @copysign(double, double) 17declare double @cos(double) 18declare double @fabs(double) 19declare double @floor(double) 20declare i8* @strcat(i8*, i8*) 21declare i8* @strncat(i8*, i8*, i32) 22declare i8* @strchr(i8*, i32) 23declare i8* @strrchr(i8*, i32) 24declare i32 @strcmp(i8*, i8*) 25declare i32 @strncmp(i8*, i8*, i64) 26declare i8* @strcpy(i8*, i8*) 27declare i8* @stpcpy(i8*, i8*) 28declare i8* @strncpy(i8*, i8*, i64) 29declare i64 @strlen(i8*) 30declare i8* @strpbrk(i8*, i8*) 31declare i64 @strspn(i8*, i8*) 32declare double @strtod(i8*, i8**) 33declare float @strtof(i8*, i8**) 34declare x86_fp80 @strtold(i8*, i8**) 35declare i64 @strtol(i8*, i8**, i32) 36declare i64 @strtoll(i8*, i8**, i32) 37declare i64 @strtoul(i8*, i8**, i32) 38declare i64 @strtoull(i8*, i8**, i32) 39declare i64 @strcspn(i8*, i8*) 40declare i32 @abs(i32) 41declare i32 @ffs(i32) 42declare i32 @ffsl(i64) 43declare i32 @ffsll(i64) 44declare i32 @fprintf(i8*, i8*) 45declare i32 @isascii(i32) 46declare i32 @isdigit(i32) 47declare i32 @toascii(i32) 48declare i64 @labs(i64) 49declare i64 @llabs(i64) 50declare i32 @printf(i8*) 51declare i32 @sprintf(i8*, i8*) 52 53define double @t1(double %x) { 54; CHECK-LABEL: @t1( 55 %ret = call double @ceil(double %x) 56 ret double %ret 57; CHECK: call double @ceil 58} 59 60define double @t2(double %x, double %y) { 61; CHECK-LABEL: @t2( 62 %ret = call double @copysign(double %x, double %y) 63 ret double %ret 64; CHECK: call double @copysign 65} 66 67define double @t3(double %x) { 68; CHECK-LABEL: @t3( 69 %call = call double @cos(double %x) 70 ret double %call 71; CHECK: call double @cos 72} 73 74define double @t4(double %x) { 75; CHECK-LABEL: @t4( 76 %ret = call double @fabs(double %x) 77 ret double %ret 78; CHECK: call double @fabs 79} 80 81define double @t5(double %x) { 82; CHECK-LABEL: @t5( 83 %ret = call double @floor(double %x) 84 ret double %ret 85; CHECK: call double @floor 86} 87 88define i8* @t6(i8* %x) { 89; CHECK-LABEL: @t6( 90 %empty = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0 91 %ret = call i8* @strcat(i8* %x, i8* %empty) 92 ret i8* %ret 93; CHECK: call i8* @strcat 94} 95 96define i8* @t7(i8* %x) { 97; CHECK-LABEL: @t7( 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) 100 ret i8* %ret 101; CHECK: call i8* @strncat 102} 103 104define i8* @t8() { 105; CHECK-LABEL: @t8( 106 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0 107 %ret = call i8* @strchr(i8* %x, i32 119) 108 ret i8* %ret 109; CHECK: call i8* @strchr 110} 111 112define i8* @t9() { 113; CHECK-LABEL: @t9( 114 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0 115 %ret = call i8* @strrchr(i8* %x, i32 119) 116 ret i8* %ret 117; CHECK: call i8* @strrchr 118} 119 120define i32 @t10() { 121; CHECK-LABEL: @t10( 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) 125 ret i32 %ret 126; CHECK: call i32 @strcmp 127} 128 129define i32 @t11() { 130; CHECK-LABEL: @t11( 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) 134 ret i32 %ret 135; CHECK: call i32 @strncmp 136} 137 138define i8* @t12(i8* %x) { 139; CHECK-LABEL: @t12( 140 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0 141 %ret = call i8* @strcpy(i8* %x, i8* %y) 142 ret i8* %ret 143; CHECK: call i8* @strcpy 144} 145 146define i8* @t13(i8* %x) { 147; CHECK-LABEL: @t13( 148 %y = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0 149 %ret = call i8* @stpcpy(i8* %x, i8* %y) 150 ret i8* %ret 151; CHECK: call i8* @stpcpy 152} 153 154define i8* @t14(i8* %x) { 155; CHECK-LABEL: @t14( 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) 158 ret i8* %ret 159; CHECK: call i8* @strncpy 160} 161 162define i64 @t15() { 163; CHECK-LABEL: @t15( 164 %x = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0 165 %ret = call i64 @strlen(i8* %x) 166 ret i64 %ret 167; CHECK: call i64 @strlen 168} 169 170define i8* @t16(i8* %x) { 171; CHECK-LABEL: @t16( 172 %y = getelementptr inbounds [1 x i8], [1 x i8]* @.str, i32 0, i32 0 173 %ret = call i8* @strpbrk(i8* %x, i8* %y) 174 ret i8* %ret 175; CHECK: call i8* @strpbrk 176} 177 178define i64 @t17(i8* %x) { 179; CHECK-LABEL: @t17( 180 %y = getelementptr inbounds [1 x i8], [1 x i8]* @.str, i32 0, i32 0 181 %ret = call i64 @strspn(i8* %x, i8* %y) 182 ret i64 %ret 183; CHECK: call i64 @strspn 184} 185 186define double @t18(i8** %y) { 187; CHECK-LABEL: @t18( 188 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0 189 %ret = call double @strtod(i8* %x, i8** %y) 190 ret double %ret 191; CHECK: call double @strtod 192} 193 194define float @t19(i8** %y) { 195; CHECK-LABEL: @t19( 196 %x = getelementptr inbounds [6 x i8], [6 x i8]* @.str4, i64 0, i64 0 197 %ret = call float @strtof(i8* %x, i8** %y) 198 ret float %ret 199; CHECK: call float @strtof 200} 201 202define x86_fp80 @t20(i8** %y) { 203; CHECK-LABEL: @t20( 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) 206 ret x86_fp80 %ret 207; CHECK: call x86_fp80 @strtold 208} 209 210define i64 @t21(i8** %y) { 211; CHECK-LABEL: @t21( 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) 214 ret i64 %ret 215; CHECK: call i64 @strtol 216} 217 218define i64 @t22(i8** %y) { 219; CHECK-LABEL: @t22( 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) 222 ret i64 %ret 223; CHECK: call i64 @strtoll 224} 225 226define i64 @t23(i8** %y) { 227; CHECK-LABEL: @t23( 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) 230 ret i64 %ret 231; CHECK: call i64 @strtoul 232} 233 234define i64 @t24(i8** %y) { 235; CHECK-LABEL: @t24( 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) 238 ret i64 %ret 239; CHECK: call i64 @strtoull 240} 241 242define i64 @t25(i8* %y) { 243; CHECK-LABEL: @t25( 244 %x = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0 245 %ret = call i64 @strcspn(i8* %x, i8* %y) 246 ret i64 %ret 247; CHECK: call i64 @strcspn 248} 249 250define i32 @t26(i32 %y) { 251; CHECK-LABEL: @t26( 252 %ret = call i32 @abs(i32 %y) 253 ret i32 %ret 254; CHECK: call i32 @abs 255} 256 257define i32 @t27(i32 %y) { 258; CHECK-LABEL: @t27( 259 %ret = call i32 @ffs(i32 %y) 260 ret i32 %ret 261; CHECK: call i32 @ffs 262} 263 264define i32 @t28(i64 %y) { 265; CHECK-LABEL: @t28( 266 %ret = call i32 @ffsl(i64 %y) 267 ret i32 %ret 268; CHECK: call i32 @ffsl 269} 270 271define i32 @t29(i64 %y) { 272; CHECK-LABEL: @t29( 273 %ret = call i32 @ffsll(i64 %y) 274 ret i32 %ret 275; CHECK: call i32 @ffsll 276} 277 278define void @t30() { 279; CHECK-LABEL: @t30( 280 %x = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0 281 call i32 @fprintf(i8* null, i8* %x) 282 ret void 283; CHECK: call i32 @fprintf 284} 285 286define i32 @t31(i32 %y) { 287; CHECK-LABEL: @t31( 288 %ret = call i32 @isascii(i32 %y) 289 ret i32 %ret 290; CHECK: call i32 @isascii 291} 292 293define i32 @t32(i32 %y) { 294; CHECK-LABEL: @t32( 295 %ret = call i32 @isdigit(i32 %y) 296 ret i32 %ret 297; CHECK: call i32 @isdigit 298} 299 300define i32 @t33(i32 %y) { 301; CHECK-LABEL: @t33( 302 %ret = call i32 @toascii(i32 %y) 303 ret i32 %ret 304; CHECK: call i32 @toascii 305} 306 307define i64 @t34(i64 %y) { 308; CHECK-LABEL: @t34( 309 %ret = call i64 @labs(i64 %y) 310 ret i64 %ret 311; CHECK: call i64 @labs 312} 313 314define i64 @t35(i64 %y) { 315; CHECK-LABEL: @t35( 316 %ret = call i64 @llabs(i64 %y) 317 ret i64 %ret 318; CHECK: call i64 @llabs 319} 320 321define void @t36() { 322; CHECK-LABEL: @t36( 323 %x = getelementptr inbounds [1 x i8], [1 x i8]* @empty, i32 0, i32 0 324 call i32 @printf(i8* %x) 325 ret void 326; CHECK: call i32 @printf 327} 328 329define void @t37(i8* %x) { 330; CHECK-LABEL: @t37( 331 %y = getelementptr inbounds [13 x i8], [13 x i8]* @.str1, i32 0, i32 0 332 call i32 @sprintf(i8* %x, i8* %y) 333 ret void 334; CHECK: call i32 @sprintf 335} 336