1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=-avx512fp16 | FileCheck %s -check-prefix=LIBCALL
3 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512fp16 | FileCheck %s -check-prefix=FP16
5 define void @test1(float %src, ptr %dest) {
6 ; LIBCALL-LABEL: test1:
8 ; LIBCALL-NEXT: pushq %rbx
9 ; LIBCALL-NEXT: .cfi_def_cfa_offset 16
10 ; LIBCALL-NEXT: .cfi_offset %rbx, -16
11 ; LIBCALL-NEXT: movq %rdi, %rbx
12 ; LIBCALL-NEXT: callq __truncsfhf2@PLT
13 ; LIBCALL-NEXT: pextrw $0, %xmm0, %eax
14 ; LIBCALL-NEXT: movw %ax, (%rbx)
15 ; LIBCALL-NEXT: popq %rbx
16 ; LIBCALL-NEXT: .cfi_def_cfa_offset 8
21 ; FP16-NEXT: vcvtss2sh %xmm0, %xmm0, %xmm0
22 ; FP16-NEXT: vmovsh %xmm0, (%rdi)
24 %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
25 store i16 %1, ptr %dest, align 2
29 define float @test2(ptr nocapture %src) {
30 ; LIBCALL-LABEL: test2:
32 ; LIBCALL-NEXT: pinsrw $0, (%rdi), %xmm0
33 ; LIBCALL-NEXT: jmp __extendhfsf2@PLT # TAILCALL
37 ; FP16-NEXT: vmovsh (%rdi), %xmm0
38 ; FP16-NEXT: vcvtsh2ss %xmm0, %xmm0, %xmm0
40 %1 = load i16, ptr %src, align 2
41 %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
45 define float @test3(float %src) nounwind uwtable readnone {
46 ; LIBCALL-LABEL: test3:
48 ; LIBCALL-NEXT: pushq %rax
49 ; LIBCALL-NEXT: .cfi_def_cfa_offset 16
50 ; LIBCALL-NEXT: callq __truncsfhf2@PLT
51 ; LIBCALL-NEXT: popq %rax
52 ; LIBCALL-NEXT: .cfi_def_cfa_offset 8
53 ; LIBCALL-NEXT: jmp __extendhfsf2@PLT # TAILCALL
57 ; FP16-NEXT: vcvtss2sh %xmm0, %xmm0, %xmm0
58 ; FP16-NEXT: vcvtsh2ss %xmm0, %xmm0, %xmm0
60 %1 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
61 %2 = tail call float @llvm.convert.from.fp16.f32(i16 %1)
65 ; FIXME: Should it be __extendhfdf2?
66 define double @test4(ptr nocapture %src) {
67 ; LIBCALL-LABEL: test4:
69 ; LIBCALL-NEXT: pushq %rax
70 ; LIBCALL-NEXT: .cfi_def_cfa_offset 16
71 ; LIBCALL-NEXT: pinsrw $0, (%rdi), %xmm0
72 ; LIBCALL-NEXT: callq __extendhfsf2@PLT
73 ; LIBCALL-NEXT: cvtss2sd %xmm0, %xmm0
74 ; LIBCALL-NEXT: popq %rax
75 ; LIBCALL-NEXT: .cfi_def_cfa_offset 8
80 ; FP16-NEXT: vmovsh (%rdi), %xmm0
81 ; FP16-NEXT: vcvtsh2sd %xmm0, %xmm0, %xmm0
83 %1 = load i16, ptr %src, align 2
84 %2 = tail call double @llvm.convert.from.fp16.f64(i16 %1)
88 define i16 @test5(double %src) {
89 ; LIBCALL-LABEL: test5:
91 ; LIBCALL-NEXT: pushq %rax
92 ; LIBCALL-NEXT: .cfi_def_cfa_offset 16
93 ; LIBCALL-NEXT: callq __truncdfhf2@PLT
94 ; LIBCALL-NEXT: pextrw $0, %xmm0, %eax
95 ; LIBCALL-NEXT: # kill: def $ax killed $ax killed $eax
96 ; LIBCALL-NEXT: popq %rcx
97 ; LIBCALL-NEXT: .cfi_def_cfa_offset 8
102 ; FP16-NEXT: vcvtsd2sh %xmm0, %xmm0, %xmm0
103 ; FP16-NEXT: vmovw %xmm0, %eax
104 ; FP16-NEXT: # kill: def $ax killed $ax killed $eax
106 %val = tail call i16 @llvm.convert.to.fp16.f64(double %src)
110 ; FIXME: Should it be __extendhfxf2?
111 define x86_fp80 @test6(ptr nocapture %src) {
112 ; LIBCALL-LABEL: test6:
114 ; LIBCALL-NEXT: pushq %rax
115 ; LIBCALL-NEXT: .cfi_def_cfa_offset 16
116 ; LIBCALL-NEXT: pinsrw $0, (%rdi), %xmm0
117 ; LIBCALL-NEXT: callq __extendhfxf2@PLT
118 ; LIBCALL-NEXT: popq %rax
119 ; LIBCALL-NEXT: .cfi_def_cfa_offset 8
124 ; FP16-NEXT: pushq %rax
125 ; FP16-NEXT: .cfi_def_cfa_offset 16
126 ; FP16-NEXT: vmovsh (%rdi), %xmm0
127 ; FP16-NEXT: callq __extendhfxf2@PLT
128 ; FP16-NEXT: popq %rax
129 ; FP16-NEXT: .cfi_def_cfa_offset 8
131 %1 = load i16, ptr %src, align 2
132 %2 = tail call x86_fp80 @llvm.convert.from.fp16.f80(i16 %1)
136 define i16 @test7(x86_fp80 %src) {
137 ; LIBCALL-LABEL: test7:
139 ; LIBCALL-NEXT: subq $24, %rsp
140 ; LIBCALL-NEXT: .cfi_def_cfa_offset 32
141 ; LIBCALL-NEXT: fldt {{[0-9]+}}(%rsp)
142 ; LIBCALL-NEXT: fstpt (%rsp)
143 ; LIBCALL-NEXT: callq __truncxfhf2@PLT
144 ; LIBCALL-NEXT: pextrw $0, %xmm0, %eax
145 ; LIBCALL-NEXT: # kill: def $ax killed $ax killed $eax
146 ; LIBCALL-NEXT: addq $24, %rsp
147 ; LIBCALL-NEXT: .cfi_def_cfa_offset 8
152 ; FP16-NEXT: subq $24, %rsp
153 ; FP16-NEXT: .cfi_def_cfa_offset 32
154 ; FP16-NEXT: fldt {{[0-9]+}}(%rsp)
155 ; FP16-NEXT: fstpt (%rsp)
156 ; FP16-NEXT: callq __truncxfhf2@PLT
157 ; FP16-NEXT: vmovw %xmm0, %eax
158 ; FP16-NEXT: # kill: def $ax killed $ax killed $eax
159 ; FP16-NEXT: addq $24, %rsp
160 ; FP16-NEXT: .cfi_def_cfa_offset 8
162 %val = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %src)
166 declare float @llvm.convert.from.fp16.f32(i16) nounwind readnone
167 declare i16 @llvm.convert.to.fp16.f32(float) nounwind readnone
168 declare double @llvm.convert.from.fp16.f64(i16) nounwind readnone
169 declare i16 @llvm.convert.to.fp16.f64(double) nounwind readnone
170 declare x86_fp80 @llvm.convert.from.fp16.f80(i16) nounwind readnone
171 declare i16 @llvm.convert.to.fp16.f80(x86_fp80) nounwind readnone