OLD | NEW |
1 ; This tries to be a comprehensive test of f32 and f64 operations. | 1 ; This tries to be a comprehensive test of f32 and f64 operations. |
2 ; The CHECK lines are only checking for basic instruction patterns | 2 ; The CHECK lines are only checking for basic instruction patterns |
3 ; that should be present regardless of the optimization level, so | 3 ; that should be present regardless of the optimization level, so |
4 ; there are no special OPTM1 match lines. | 4 ; there are no special OPTM1 match lines. |
5 | 5 |
6 ; TODO(jvoung): fix extra "CALLTARGETS" run. The llvm-objdump symbolizer | |
7 ; doesn't know how to symbolize non-section-local functions. | |
8 ; The newer LLVM 3.6 one does work, but watch out for other bugs. | |
9 | |
10 ; RUN: %p2i -i %s --args -O2 --verbose none \ | |
11 ; RUN: | FileCheck --check-prefix=CALLTARGETS %s | |
12 ; RUN: %p2i -i %s --args -O2 --verbose none \ | 6 ; RUN: %p2i -i %s --args -O2 --verbose none \ |
13 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | 7 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
14 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s | 8 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
15 ; RUN: %p2i -i %s --args -Om1 --verbose none \ | 9 ; RUN: %p2i -i %s --args -Om1 --verbose none \ |
16 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | 10 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
17 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s | 11 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
18 | 12 |
19 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 13 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
20 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 14 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
21 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 | 15 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 |
(...skipping 18 matching lines...) Expand all Loading... |
40 define internal i32 @passFpArgs(float %a, double %b, float %c, double %d, float
%e, double %f) { | 34 define internal i32 @passFpArgs(float %a, double %b, float %c, double %d, float
%e, double %f) { |
41 entry: | 35 entry: |
42 %call = call i32 @ignoreFpArgsNoInline(float %a, i32 123, double %b) | 36 %call = call i32 @ignoreFpArgsNoInline(float %a, i32 123, double %b) |
43 %call1 = call i32 @ignoreFpArgsNoInline(float %c, i32 123, double %d) | 37 %call1 = call i32 @ignoreFpArgsNoInline(float %c, i32 123, double %d) |
44 %call2 = call i32 @ignoreFpArgsNoInline(float %e, i32 123, double %f) | 38 %call2 = call i32 @ignoreFpArgsNoInline(float %e, i32 123, double %f) |
45 %add = add i32 %call1, %call | 39 %add = add i32 %call1, %call |
46 %add3 = add i32 %add, %call2 | 40 %add3 = add i32 %add, %call2 |
47 ret i32 %add3 | 41 ret i32 %add3 |
48 } | 42 } |
49 ; CHECK-LABEL: passFpArgs | 43 ; CHECK-LABEL: passFpArgs |
50 ; CALLTARGETS-LABEL: passFpArgs | |
51 ; CHECK: mov dword ptr [esp + 4], 123 | 44 ; CHECK: mov dword ptr [esp + 4], 123 |
52 ; CHECK: call -4 | 45 ; CHECK: call ignoreFpArgsNoInline |
53 ; CALLTARGETS: .long ignoreFpArgsNoInline | |
54 ; CHECK: mov dword ptr [esp + 4], 123 | 46 ; CHECK: mov dword ptr [esp + 4], 123 |
55 ; CHECK: call -4 | 47 ; CHECK: call ignoreFpArgsNoInline |
56 ; CALLTARGETS: .long ignoreFpArgsNoInline | |
57 ; CHECK: mov dword ptr [esp + 4], 123 | 48 ; CHECK: mov dword ptr [esp + 4], 123 |
58 ; CHECK: call -4 | 49 ; CHECK: call ignoreFpArgsNoInline |
59 ; CALLTARGETS: .long ignoreFpArgsNoInline | |
60 | 50 |
61 declare i32 @ignoreFpArgsNoInline(float %x, i32 %y, double %z) | 51 declare i32 @ignoreFpArgsNoInline(float %x, i32 %y, double %z) |
62 | 52 |
63 define internal i32 @passFpConstArg(float %a, double %b) { | 53 define internal i32 @passFpConstArg(float %a, double %b) { |
64 entry: | 54 entry: |
65 %call = call i32 @ignoreFpArgsNoInline(float %a, i32 123, double 2.340000e+00) | 55 %call = call i32 @ignoreFpArgsNoInline(float %a, i32 123, double 2.340000e+00) |
66 ret i32 %call | 56 ret i32 %call |
67 } | 57 } |
68 ; CHECK-LABEL: passFpConstArg | 58 ; CHECK-LABEL: passFpConstArg |
69 ; CALLTARGETS-LABEL: passFpConstArg | |
70 ; CHECK: mov dword ptr [esp + 4], 123 | 59 ; CHECK: mov dword ptr [esp + 4], 123 |
71 ; CHECK: call -4 | 60 ; CHECK: call ignoreFpArgsNoInline |
72 ; CALLTARGETS: .long ignoreFpArgsNoInline | |
73 | 61 |
74 define internal i32 @passFp32ConstArg(float %a) { | 62 define internal i32 @passFp32ConstArg(float %a) { |
75 entry: | 63 entry: |
76 %call = call i32 @ignoreFp32ArgsNoInline(float %a, i32 123, float 2.0) | 64 %call = call i32 @ignoreFp32ArgsNoInline(float %a, i32 123, float 2.0) |
77 ret i32 %call | 65 ret i32 %call |
78 } | 66 } |
79 ; CHECK-LABEL: passFp32ConstArg | 67 ; CHECK-LABEL: passFp32ConstArg |
80 ; CHECK: mov dword ptr [esp + 4], 123 | 68 ; CHECK: mov dword ptr [esp + 4], 123 |
81 ; CHECK: movss dword ptr [esp + 8] | 69 ; CHECK: movss dword ptr [esp + 8] |
82 ; CHECK: call ignoreFp32ArgsNoInline | 70 ; CHECK: call ignoreFp32ArgsNoInline |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 ; CHECK-LABEL: divDouble | 173 ; CHECK-LABEL: divDouble |
186 ; CHECK: divsd | 174 ; CHECK: divsd |
187 ; CHECK: fld | 175 ; CHECK: fld |
188 | 176 |
189 define internal float @remFloat(float %a, float %b) { | 177 define internal float @remFloat(float %a, float %b) { |
190 entry: | 178 entry: |
191 %div = frem float %a, %b | 179 %div = frem float %a, %b |
192 ret float %div | 180 ret float %div |
193 } | 181 } |
194 ; CHECK-LABEL: remFloat | 182 ; CHECK-LABEL: remFloat |
195 ; CALLTARGETS-LABEL: remFloat | 183 ; CHECK: call fmodf |
196 ; CHECK: call -4 | |
197 ; CALLTARGETS: .long fmodf | |
198 | 184 |
199 define internal double @remDouble(double %a, double %b) { | 185 define internal double @remDouble(double %a, double %b) { |
200 entry: | 186 entry: |
201 %div = frem double %a, %b | 187 %div = frem double %a, %b |
202 ret double %div | 188 ret double %div |
203 } | 189 } |
204 ; CHECK-LABEL: remDouble | 190 ; CHECK-LABEL: remDouble |
205 ; CALLTARGETS-LABEL: remDouble | 191 ; CHECK: call fmod |
206 ; CHECK: call -4 | |
207 ; CALLTARGETS: .long fmod | |
208 | 192 |
209 define internal float @fptrunc(double %a) { | 193 define internal float @fptrunc(double %a) { |
210 entry: | 194 entry: |
211 %conv = fptrunc double %a to float | 195 %conv = fptrunc double %a to float |
212 ret float %conv | 196 ret float %conv |
213 } | 197 } |
214 ; CHECK-LABEL: fptrunc | 198 ; CHECK-LABEL: fptrunc |
215 ; CHECK: cvtsd2ss | 199 ; CHECK: cvtsd2ss |
216 ; CHECK: fld | 200 ; CHECK: fld |
217 | 201 |
218 define internal double @fpext(float %a) { | 202 define internal double @fpext(float %a) { |
219 entry: | 203 entry: |
220 %conv = fpext float %a to double | 204 %conv = fpext float %a to double |
221 ret double %conv | 205 ret double %conv |
222 } | 206 } |
223 ; CHECK-LABEL: fpext | 207 ; CHECK-LABEL: fpext |
224 ; CHECK: cvtss2sd | 208 ; CHECK: cvtss2sd |
225 ; CHECK: fld | 209 ; CHECK: fld |
226 | 210 |
227 define internal i64 @doubleToSigned64(double %a) { | 211 define internal i64 @doubleToSigned64(double %a) { |
228 entry: | 212 entry: |
229 %conv = fptosi double %a to i64 | 213 %conv = fptosi double %a to i64 |
230 ret i64 %conv | 214 ret i64 %conv |
231 } | 215 } |
232 ; CHECK-LABEL: doubleToSigned64 | 216 ; CHECK-LABEL: doubleToSigned64 |
233 ; CALLTARGETS-LABEL: doubleToSigned64 | 217 ; CHECK: call cvtdtosi64 |
234 ; CHECK: call -4 | |
235 ; CALLTARGETS: .long cvtdtosi64 | |
236 | 218 |
237 define internal i64 @floatToSigned64(float %a) { | 219 define internal i64 @floatToSigned64(float %a) { |
238 entry: | 220 entry: |
239 %conv = fptosi float %a to i64 | 221 %conv = fptosi float %a to i64 |
240 ret i64 %conv | 222 ret i64 %conv |
241 } | 223 } |
242 ; CHECK-LABEL: floatToSigned64 | 224 ; CHECK-LABEL: floatToSigned64 |
243 ; CALLTARGETS-LABEL: floatToSigned64 | 225 ; CHECK: call cvtftosi64 |
244 ; CHECK: call -4 | |
245 ; CALLTARGETS: .long cvtftosi64 | |
246 | 226 |
247 define internal i64 @doubleToUnsigned64(double %a) { | 227 define internal i64 @doubleToUnsigned64(double %a) { |
248 entry: | 228 entry: |
249 %conv = fptoui double %a to i64 | 229 %conv = fptoui double %a to i64 |
250 ret i64 %conv | 230 ret i64 %conv |
251 } | 231 } |
252 ; CHECK-LABEL: doubleToUnsigned64 | 232 ; CHECK-LABEL: doubleToUnsigned64 |
253 ; CALLTARGETS-LABEL: doubleToUnsigned64 | 233 ; CHECK: call cvtdtoui64 |
254 ; CHECK: call -4 | |
255 ; CALLTARGETS: .long cvtdtoui64 | |
256 | 234 |
257 define internal i64 @floatToUnsigned64(float %a) { | 235 define internal i64 @floatToUnsigned64(float %a) { |
258 entry: | 236 entry: |
259 %conv = fptoui float %a to i64 | 237 %conv = fptoui float %a to i64 |
260 ret i64 %conv | 238 ret i64 %conv |
261 } | 239 } |
262 ; CHECK-LABEL: floatToUnsigned64 | 240 ; CHECK-LABEL: floatToUnsigned64 |
263 ; CALLTARGETS-LABEL: floatToUnsigned64 | 241 ; CHECK: call cvtftoui64 |
264 ; CHECK: call -4 | |
265 ; CALLTARGETS: .long cvtftoui64 | |
266 | 242 |
267 define internal i32 @doubleToSigned32(double %a) { | 243 define internal i32 @doubleToSigned32(double %a) { |
268 entry: | 244 entry: |
269 %conv = fptosi double %a to i32 | 245 %conv = fptosi double %a to i32 |
270 ret i32 %conv | 246 ret i32 %conv |
271 } | 247 } |
272 ; CHECK-LABEL: doubleToSigned32 | 248 ; CHECK-LABEL: doubleToSigned32 |
273 ; CHECK: cvttsd2si | 249 ; CHECK: cvttsd2si |
274 | 250 |
275 define internal i32 @doubleToSigned32Const() { | 251 define internal i32 @doubleToSigned32Const() { |
(...skipping 11 matching lines...) Expand all Loading... |
287 } | 263 } |
288 ; CHECK-LABEL: floatToSigned32 | 264 ; CHECK-LABEL: floatToSigned32 |
289 ; CHECK: cvttss2si | 265 ; CHECK: cvttss2si |
290 | 266 |
291 define internal i32 @doubleToUnsigned32(double %a) { | 267 define internal i32 @doubleToUnsigned32(double %a) { |
292 entry: | 268 entry: |
293 %conv = fptoui double %a to i32 | 269 %conv = fptoui double %a to i32 |
294 ret i32 %conv | 270 ret i32 %conv |
295 } | 271 } |
296 ; CHECK-LABEL: doubleToUnsigned32 | 272 ; CHECK-LABEL: doubleToUnsigned32 |
297 ; CALLTARGETS-LABEL: doubleToUnsigned32 | 273 ; CHECK: call cvtdtoui32 |
298 ; CHECK: call -4 | |
299 ; CALLTARGETS: .long cvtdtoui32 | |
300 | 274 |
301 define internal i32 @floatToUnsigned32(float %a) { | 275 define internal i32 @floatToUnsigned32(float %a) { |
302 entry: | 276 entry: |
303 %conv = fptoui float %a to i32 | 277 %conv = fptoui float %a to i32 |
304 ret i32 %conv | 278 ret i32 %conv |
305 } | 279 } |
306 ; CHECK-LABEL: floatToUnsigned32 | 280 ; CHECK-LABEL: floatToUnsigned32 |
307 ; CALLTARGETS-LABEL: floatToUnsigned32 | 281 ; CHECK: call cvtftoui32 |
308 ; CHECK: call -4 | |
309 ; CALLTARGETS: .long cvtftoui32 | |
310 | 282 |
311 | 283 |
312 define internal i32 @doubleToSigned16(double %a) { | 284 define internal i32 @doubleToSigned16(double %a) { |
313 entry: | 285 entry: |
314 %conv = fptosi double %a to i16 | 286 %conv = fptosi double %a to i16 |
315 %conv.ret_ext = sext i16 %conv to i32 | 287 %conv.ret_ext = sext i16 %conv to i32 |
316 ret i32 %conv.ret_ext | 288 ret i32 %conv.ret_ext |
317 } | 289 } |
318 ; CHECK-LABEL: doubleToSigned16 | 290 ; CHECK-LABEL: doubleToSigned16 |
319 ; CHECK: cvttsd2si | 291 ; CHECK: cvttsd2si |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 ; CHECK-LABEL: floatToUnsigned1 | 380 ; CHECK-LABEL: floatToUnsigned1 |
409 ; CHECK: cvttss2si | 381 ; CHECK: cvttss2si |
410 ; CHECK: and eax, 1 | 382 ; CHECK: and eax, 1 |
411 | 383 |
412 define internal double @signed64ToDouble(i64 %a) { | 384 define internal double @signed64ToDouble(i64 %a) { |
413 entry: | 385 entry: |
414 %conv = sitofp i64 %a to double | 386 %conv = sitofp i64 %a to double |
415 ret double %conv | 387 ret double %conv |
416 } | 388 } |
417 ; CHECK-LABEL: signed64ToDouble | 389 ; CHECK-LABEL: signed64ToDouble |
418 ; CALLTARGETS-LABEL: signed64ToDouble | 390 ; CHECK: call cvtsi64tod |
419 ; CHECK: call -4 | |
420 ; CALLTARGETS: .long cvtsi64tod | |
421 ; CHECK: fstp qword | 391 ; CHECK: fstp qword |
422 | 392 |
423 define internal float @signed64ToFloat(i64 %a) { | 393 define internal float @signed64ToFloat(i64 %a) { |
424 entry: | 394 entry: |
425 %conv = sitofp i64 %a to float | 395 %conv = sitofp i64 %a to float |
426 ret float %conv | 396 ret float %conv |
427 } | 397 } |
428 ; CHECK-LABEL: signed64ToFloat | 398 ; CHECK-LABEL: signed64ToFloat |
429 ; CALLTARGETS-LABEL: signed64ToFloat | 399 ; CHECK: call cvtsi64tof |
430 ; CHECK: call -4 | |
431 ; CALLTARGETS: .long cvtsi64tof | |
432 ; CHECK: fstp dword | 400 ; CHECK: fstp dword |
433 | 401 |
434 define internal double @unsigned64ToDouble(i64 %a) { | 402 define internal double @unsigned64ToDouble(i64 %a) { |
435 entry: | 403 entry: |
436 %conv = uitofp i64 %a to double | 404 %conv = uitofp i64 %a to double |
437 ret double %conv | 405 ret double %conv |
438 } | 406 } |
439 ; CHECK-LABEL: unsigned64ToDouble | 407 ; CHECK-LABEL: unsigned64ToDouble |
440 ; CALLTARGETS-LABEL: unsigned64ToDouble | 408 ; CHECK: call cvtui64tod |
441 ; CHECK: call -4 | |
442 ; CALLTARGETS: .long cvtui64tod | |
443 ; CHECK: fstp | 409 ; CHECK: fstp |
444 | 410 |
445 define internal float @unsigned64ToFloat(i64 %a) { | 411 define internal float @unsigned64ToFloat(i64 %a) { |
446 entry: | 412 entry: |
447 %conv = uitofp i64 %a to float | 413 %conv = uitofp i64 %a to float |
448 ret float %conv | 414 ret float %conv |
449 } | 415 } |
450 ; CHECK-LABEL: unsigned64ToFloat | 416 ; CHECK-LABEL: unsigned64ToFloat |
451 ; CALLTARGETS-LABEL: unsigned64ToFloat | 417 ; CHECK: call cvtui64tof |
452 ; CHECK: call -4 | |
453 ; CALLTARGETS: .long cvtui64tof | |
454 ; CHECK: fstp | 418 ; CHECK: fstp |
455 | 419 |
456 define internal double @unsigned64ToDoubleConst() { | 420 define internal double @unsigned64ToDoubleConst() { |
457 entry: | 421 entry: |
458 %conv = uitofp i64 12345678901234 to double | 422 %conv = uitofp i64 12345678901234 to double |
459 ret double %conv | 423 ret double %conv |
460 } | 424 } |
461 ; CHECK-LABEL: unsigned64ToDouble | 425 ; CHECK-LABEL: unsigned64ToDouble |
462 ; CALLTARGETS-LABEL: unsigned64ToDouble | |
463 ; CHECK: mov dword ptr [esp + 4], 2874 | 426 ; CHECK: mov dword ptr [esp + 4], 2874 |
464 ; CHECK: mov dword ptr [esp], 1942892530 | 427 ; CHECK: mov dword ptr [esp], 1942892530 |
465 ; CHECK: call -4 | 428 ; CHECK: call cvtui64tod |
466 ; CALLTARGETS: .long cvtui64tod | |
467 ; CHECK: fstp | 429 ; CHECK: fstp |
468 | 430 |
469 define internal double @signed32ToDouble(i32 %a) { | 431 define internal double @signed32ToDouble(i32 %a) { |
470 entry: | 432 entry: |
471 %conv = sitofp i32 %a to double | 433 %conv = sitofp i32 %a to double |
472 ret double %conv | 434 ret double %conv |
473 } | 435 } |
474 ; CHECK-LABEL: signed32ToDouble | 436 ; CHECK-LABEL: signed32ToDouble |
475 ; CHECK: cvtsi2sd | 437 ; CHECK: cvtsi2sd |
476 ; CHECK: fld | 438 ; CHECK: fld |
(...skipping 15 matching lines...) Expand all Loading... |
492 ; CHECK-LABEL: signed32ToFloat | 454 ; CHECK-LABEL: signed32ToFloat |
493 ; CHECK: cvtsi2ss | 455 ; CHECK: cvtsi2ss |
494 ; CHECK: fld | 456 ; CHECK: fld |
495 | 457 |
496 define internal double @unsigned32ToDouble(i32 %a) { | 458 define internal double @unsigned32ToDouble(i32 %a) { |
497 entry: | 459 entry: |
498 %conv = uitofp i32 %a to double | 460 %conv = uitofp i32 %a to double |
499 ret double %conv | 461 ret double %conv |
500 } | 462 } |
501 ; CHECK-LABEL: unsigned32ToDouble | 463 ; CHECK-LABEL: unsigned32ToDouble |
502 ; CALLTARGETS-LABEL: unsigned32ToDouble | 464 ; CHECK: call cvtui32tod |
503 ; CHECK: call -4 | |
504 ; CALLTARGETS: .long cvtui32tod | |
505 ; CHECK: fstp qword | 465 ; CHECK: fstp qword |
506 | 466 |
507 define internal float @unsigned32ToFloat(i32 %a) { | 467 define internal float @unsigned32ToFloat(i32 %a) { |
508 entry: | 468 entry: |
509 %conv = uitofp i32 %a to float | 469 %conv = uitofp i32 %a to float |
510 ret float %conv | 470 ret float %conv |
511 } | 471 } |
512 ; CHECK-LABEL: unsigned32ToFloat | 472 ; CHECK-LABEL: unsigned32ToFloat |
513 ; CALLTARGETS-LABEL: unsigned32ToFloat | 473 ; CHECK: call cvtui32tof |
514 ; CHECK: call -4 | |
515 ; CALLTARGETS: .long cvtui32tof | |
516 ; CHECK: fstp dword | 474 ; CHECK: fstp dword |
517 | 475 |
518 define internal double @signed16ToDouble(i32 %a) { | 476 define internal double @signed16ToDouble(i32 %a) { |
519 entry: | 477 entry: |
520 %a.arg_trunc = trunc i32 %a to i16 | 478 %a.arg_trunc = trunc i32 %a to i16 |
521 %conv = sitofp i16 %a.arg_trunc to double | 479 %conv = sitofp i16 %a.arg_trunc to double |
522 ret double %conv | 480 ret double %conv |
523 } | 481 } |
524 ; CHECK-LABEL: signed16ToDouble | 482 ; CHECK-LABEL: signed16ToDouble |
525 ; CHECK: cvtsi2sd | 483 ; CHECK: cvtsi2sd |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 define internal double @selectDoubleVarVar(double %a, double %b) { | 1185 define internal double @selectDoubleVarVar(double %a, double %b) { |
1228 entry: | 1186 entry: |
1229 %cmp = fcmp olt double %a, %b | 1187 %cmp = fcmp olt double %a, %b |
1230 %cond = select i1 %cmp, double %a, double %b | 1188 %cond = select i1 %cmp, double %a, double %b |
1231 ret double %cond | 1189 ret double %cond |
1232 } | 1190 } |
1233 ; CHECK-LABEL: selectDoubleVarVar | 1191 ; CHECK-LABEL: selectDoubleVarVar |
1234 ; CHECK: ucomisd | 1192 ; CHECK: ucomisd |
1235 ; CHECK: ja {{[0-9]}} | 1193 ; CHECK: ja {{[0-9]}} |
1236 ; CHECK: fld | 1194 ; CHECK: fld |
OLD | NEW |