1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-apple-macosx %s -o - | FileCheck %s --check-prefix=CHECK-SOFT
3 ; RUN: llc -mtriple=x86_64-apple-macosx -mattr=+f16c %s -o - | FileCheck %s --check-prefix=CHECK-F16C
4 ; RUN: llc -mtriple=x86_64-apple-macosx -mattr=+avx512fp16 %s -o - | FileCheck %s --check-prefix=CHECK-FP16
6 define void @truncsfhf(float %in, ptr %ptr) nounwind {
7 ; CHECK-SOFT-LABEL: truncsfhf:
8 ; CHECK-SOFT: ## %bb.0:
9 ; CHECK-SOFT-NEXT: pushq %rbx
10 ; CHECK-SOFT-NEXT: movq %rdi, %rbx
11 ; CHECK-SOFT-NEXT: callq ___truncsfhf2
12 ; CHECK-SOFT-NEXT: movw %ax, (%rbx)
13 ; CHECK-SOFT-NEXT: popq %rbx
14 ; CHECK-SOFT-NEXT: retq
16 ; CHECK-F16C-LABEL: truncsfhf:
17 ; CHECK-F16C: ## %bb.0:
18 ; CHECK-F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
19 ; CHECK-F16C-NEXT: vmovd %xmm0, %eax
20 ; CHECK-F16C-NEXT: movw %ax, (%rdi)
21 ; CHECK-F16C-NEXT: retq
23 ; CHECK-FP16-LABEL: truncsfhf:
24 ; CHECK-FP16: ## %bb.0:
25 ; CHECK-FP16-NEXT: vcvtss2sh %xmm0, %xmm0, %xmm0
26 ; CHECK-FP16-NEXT: vmovsh %xmm0, (%rdi)
27 ; CHECK-FP16-NEXT: retq
31 %half = fptrunc float %in to half
32 store half %half, ptr %ptr
36 define void @truncdfhf(double %in, ptr %ptr) nounwind {
37 ; CHECK-SOFT-LABEL: truncdfhf:
38 ; CHECK-SOFT: ## %bb.0:
39 ; CHECK-SOFT-NEXT: pushq %rbx
40 ; CHECK-SOFT-NEXT: movq %rdi, %rbx
41 ; CHECK-SOFT-NEXT: callq ___truncdfhf2
42 ; CHECK-SOFT-NEXT: movw %ax, (%rbx)
43 ; CHECK-SOFT-NEXT: popq %rbx
44 ; CHECK-SOFT-NEXT: retq
46 ; CHECK-F16C-LABEL: truncdfhf:
47 ; CHECK-F16C: ## %bb.0:
48 ; CHECK-F16C-NEXT: pushq %rbx
49 ; CHECK-F16C-NEXT: movq %rdi, %rbx
50 ; CHECK-F16C-NEXT: callq ___truncdfhf2
51 ; CHECK-F16C-NEXT: movw %ax, (%rbx)
52 ; CHECK-F16C-NEXT: popq %rbx
53 ; CHECK-F16C-NEXT: retq
55 ; CHECK-FP16-LABEL: truncdfhf:
56 ; CHECK-FP16: ## %bb.0:
57 ; CHECK-FP16-NEXT: vcvtsd2sh %xmm0, %xmm0, %xmm0
58 ; CHECK-FP16-NEXT: vmovsh %xmm0, (%rdi)
59 ; CHECK-FP16-NEXT: retq
63 %half = fptrunc double %in to half
64 store half %half, ptr %ptr
68 define float @extendhfsf(ptr %ptr) nounwind {
69 ; CHECK-SOFT-LABEL: extendhfsf:
70 ; CHECK-SOFT: ## %bb.0:
71 ; CHECK-SOFT-NEXT: pushq %rax
72 ; CHECK-SOFT-NEXT: movzwl (%rdi), %edi
73 ; CHECK-SOFT-NEXT: callq ___extendhfsf2
74 ; CHECK-SOFT-NEXT: popq %rax
75 ; CHECK-SOFT-NEXT: retq
77 ; CHECK-F16C-LABEL: extendhfsf:
78 ; CHECK-F16C: ## %bb.0:
79 ; CHECK-F16C-NEXT: movzwl (%rdi), %eax
80 ; CHECK-F16C-NEXT: vmovd %eax, %xmm0
81 ; CHECK-F16C-NEXT: vcvtph2ps %xmm0, %xmm0
82 ; CHECK-F16C-NEXT: retq
84 ; CHECK-FP16-LABEL: extendhfsf:
85 ; CHECK-FP16: ## %bb.0:
86 ; CHECK-FP16-NEXT: vmovsh (%rdi), %xmm0
87 ; CHECK-FP16-NEXT: vcvtsh2ss %xmm0, %xmm0, %xmm0
88 ; CHECK-FP16-NEXT: retq
92 %in = load half, ptr %ptr
93 %float = fpext half %in to float
97 define void @strict_truncsfhf(float %in, ptr %ptr) nounwind strictfp {
98 ; CHECK-SOFT-LABEL: strict_truncsfhf:
99 ; CHECK-SOFT: ## %bb.0:
100 ; CHECK-SOFT-NEXT: pushq %rbx
101 ; CHECK-SOFT-NEXT: movq %rdi, %rbx
102 ; CHECK-SOFT-NEXT: callq ___truncsfhf2
103 ; CHECK-SOFT-NEXT: movw %ax, (%rbx)
104 ; CHECK-SOFT-NEXT: popq %rbx
105 ; CHECK-SOFT-NEXT: retq
107 ; CHECK-F16C-LABEL: strict_truncsfhf:
108 ; CHECK-F16C: ## %bb.0:
109 ; CHECK-F16C-NEXT: vxorps %xmm1, %xmm1, %xmm1
110 ; CHECK-F16C-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
111 ; CHECK-F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
112 ; CHECK-F16C-NEXT: vmovd %xmm0, %eax
113 ; CHECK-F16C-NEXT: movw %ax, (%rdi)
114 ; CHECK-F16C-NEXT: retq
116 ; CHECK-FP16-LABEL: strict_truncsfhf:
117 ; CHECK-FP16: ## %bb.0:
118 ; CHECK-FP16-NEXT: vcvtss2sh %xmm0, %xmm0, %xmm0
119 ; CHECK-FP16-NEXT: vmovsh %xmm0, (%rdi)
120 ; CHECK-FP16-NEXT: retq
124 %half = call half @llvm.experimental.constrained.fptrunc.f16.f32(float %in, metadata !"round.tonearest", metadata !"fpexcept.strict")
125 store half %half, ptr %ptr
129 define void @strict_truncdfhf(double %in, ptr %ptr) nounwind strictfp {
130 ; CHECK-SOFT-LABEL: strict_truncdfhf:
131 ; CHECK-SOFT: ## %bb.0:
132 ; CHECK-SOFT-NEXT: pushq %rbx
133 ; CHECK-SOFT-NEXT: movq %rdi, %rbx
134 ; CHECK-SOFT-NEXT: callq ___truncdfhf2
135 ; CHECK-SOFT-NEXT: movw %ax, (%rbx)
136 ; CHECK-SOFT-NEXT: popq %rbx
137 ; CHECK-SOFT-NEXT: retq
139 ; CHECK-F16C-LABEL: strict_truncdfhf:
140 ; CHECK-F16C: ## %bb.0:
141 ; CHECK-F16C-NEXT: pushq %rbx
142 ; CHECK-F16C-NEXT: movq %rdi, %rbx
143 ; CHECK-F16C-NEXT: callq ___truncdfhf2
144 ; CHECK-F16C-NEXT: movw %ax, (%rbx)
145 ; CHECK-F16C-NEXT: popq %rbx
146 ; CHECK-F16C-NEXT: retq
148 ; CHECK-FP16-LABEL: strict_truncdfhf:
149 ; CHECK-FP16: ## %bb.0:
150 ; CHECK-FP16-NEXT: vcvtsd2sh %xmm0, %xmm0, %xmm0
151 ; CHECK-FP16-NEXT: vmovsh %xmm0, (%rdi)
152 ; CHECK-FP16-NEXT: retq
155 %half = call half @llvm.experimental.constrained.fptrunc.f16.f64(double %in, metadata !"round.tonearest", metadata !"fpexcept.strict")
156 store half %half, ptr %ptr
160 define float @strict_extendhfsf(ptr %ptr) nounwind strictfp {
161 ; CHECK-SOFT-LABEL: strict_extendhfsf:
162 ; CHECK-SOFT: ## %bb.0:
163 ; CHECK-SOFT-NEXT: pushq %rax
164 ; CHECK-SOFT-NEXT: movzwl (%rdi), %edi
165 ; CHECK-SOFT-NEXT: callq ___extendhfsf2
166 ; CHECK-SOFT-NEXT: popq %rax
167 ; CHECK-SOFT-NEXT: retq
169 ; CHECK-F16C-LABEL: strict_extendhfsf:
170 ; CHECK-F16C: ## %bb.0:
171 ; CHECK-F16C-NEXT: movzwl (%rdi), %eax
172 ; CHECK-F16C-NEXT: vmovd %eax, %xmm0
173 ; CHECK-F16C-NEXT: vcvtph2ps %xmm0, %xmm0
174 ; CHECK-F16C-NEXT: retq
176 ; CHECK-FP16-LABEL: strict_extendhfsf:
177 ; CHECK-FP16: ## %bb.0:
178 ; CHECK-FP16-NEXT: vmovsh (%rdi), %xmm0
179 ; CHECK-FP16-NEXT: vcvtsh2ss %xmm0, %xmm0, %xmm0
180 ; CHECK-FP16-NEXT: retq
183 %in = load half, ptr %ptr
184 %float = call float @llvm.experimental.constrained.fpext.f32.f16(half %in, metadata !"fpexcept.strict")
188 declare half @llvm.experimental.constrained.fptrunc.f16.f32(float, metadata, metadata)
189 declare half @llvm.experimental.constrained.fptrunc.f16.f64(double, metadata, metadata)
190 declare float @llvm.experimental.constrained.fpext.f32.f16(half, metadata)