xref: /llvm-project/llvm/test/CodeGen/X86/fastmath-float-half-conversion.ll (revision 02fe96b24018bb8ce65cb264e0621459507cf989)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+f16c < %s | FileCheck %s --check-prefix=ALL
3; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx < %s | FileCheck %s --check-prefix=ALL
4
5define zeroext i16 @test1_fast(double %d) #0 {
6; ALL-LABEL: test1_fast:
7; ALL:       # %bb.0: # %entry
8; ALL-NEXT:    pushq %rax
9; ALL-NEXT:    callq __truncdfhf2@PLT
10; ALL-NEXT:    vpextrw $0, %xmm0, %eax
11; ALL-NEXT:    # kill: def $ax killed $ax killed $eax
12; ALL-NEXT:    popq %rcx
13; ALL-NEXT:    retq
14entry:
15  %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
16  ret i16 %0
17}
18
19define zeroext i16 @test2_fast(x86_fp80 %d) #0 {
20; ALL-LABEL: test2_fast:
21; ALL:       # %bb.0: # %entry
22; ALL-NEXT:    subq $24, %rsp
23; ALL-NEXT:    fldt {{[0-9]+}}(%rsp)
24; ALL-NEXT:    fstpt (%rsp)
25; ALL-NEXT:    callq __truncxfhf2@PLT
26; ALL-NEXT:    vpextrw $0, %xmm0, %eax
27; ALL-NEXT:    # kill: def $ax killed $ax killed $eax
28; ALL-NEXT:    addq $24, %rsp
29; ALL-NEXT:    retq
30entry:
31  %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
32  ret i16 %0
33}
34
35define zeroext i16 @test1(double %d) #1 {
36; ALL-LABEL: test1:
37; ALL:       # %bb.0: # %entry
38; ALL-NEXT:    pushq %rax
39; ALL-NEXT:    callq __truncdfhf2@PLT
40; ALL-NEXT:    vpextrw $0, %xmm0, %eax
41; ALL-NEXT:    # kill: def $ax killed $ax killed $eax
42; ALL-NEXT:    popq %rcx
43; ALL-NEXT:    retq
44entry:
45  %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
46  ret i16 %0
47}
48
49define zeroext i16 @test2(x86_fp80 %d) #1 {
50; ALL-LABEL: test2:
51; ALL:       # %bb.0: # %entry
52; ALL-NEXT:    subq $24, %rsp
53; ALL-NEXT:    fldt {{[0-9]+}}(%rsp)
54; ALL-NEXT:    fstpt (%rsp)
55; ALL-NEXT:    callq __truncxfhf2@PLT
56; ALL-NEXT:    vpextrw $0, %xmm0, %eax
57; ALL-NEXT:    # kill: def $ax killed $ax killed $eax
58; ALL-NEXT:    addq $24, %rsp
59; ALL-NEXT:    retq
60entry:
61  %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
62  ret i16 %0
63}
64
65declare i16 @llvm.convert.to.fp16.f64(double)
66declare i16 @llvm.convert.to.fp16.f80(x86_fp80)
67
68attributes #0 = { nounwind readnone "unsafe-fp-math"="true" "use-soft-float"="false" }
69attributes #1 = { nounwind readnone "unsafe-fp-math"="false" "use-soft-float"="false" }
70