1 ; Test that -disable-simplify-libcalls is wired up correctly. 2 ; 3 ; RUN: opt < %s -instcombine -disable-simplify-libcalls -S | FileCheck %s 4 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" 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 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*) 40 declare i32 @abs(i32) 41 declare i32 @ffs(i32) 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*) 52 53 define 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 60 define 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 67 define 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 74 define 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 81 define 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 88 define 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 96 define 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 104 define 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 112 define 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 120 define 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 129 define 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 138 define 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 146 define 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 154 define 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 162 define 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 170 define 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 178 define 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 186 define 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 194 define 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 202 define 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 210 define 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 218 define 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 226 define 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 234 define 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 242 define 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 250 define 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 257 define 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 264 define 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 271 define 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 278 define 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 286 define 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 293 define 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 300 define 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 307 define 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 314 define 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 321 define 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 329 define 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