1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc -mtriple=aarch64 -global-isel=0 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3 ; RUN: llc -mtriple=aarch64 -global-isel=1 -verify-machineinstrs %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
5 define float @fptrunc_f64_f32(double %a) {
6 ; CHECK-LABEL: fptrunc_f64_f32:
7 ; CHECK: // %bb.0: // %entry
8 ; CHECK-NEXT: fcvt s0, d0
11 %c = fptrunc double %a to float
15 define half @fptrunc_f64_f16(double %a) {
16 ; CHECK-LABEL: fptrunc_f64_f16:
17 ; CHECK: // %bb.0: // %entry
18 ; CHECK-NEXT: fcvt h0, d0
21 %c = fptrunc double %a to half
25 define half @fptrunc_f32_f16(float %a) {
26 ; CHECK-LABEL: fptrunc_f32_f16:
27 ; CHECK: // %bb.0: // %entry
28 ; CHECK-NEXT: fcvt h0, s0
31 %c = fptrunc float %a to half
36 define half @fptrunc_f128_f16(fp128 %a) {
37 ; CHECK-SD-LABEL: fptrunc_f128_f16:
38 ; CHECK-SD: // %bb.0: // %entry
39 ; CHECK-SD-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
40 ; CHECK-SD-NEXT: .cfi_def_cfa_offset 16
41 ; CHECK-SD-NEXT: .cfi_offset w30, -16
42 ; CHECK-SD-NEXT: bl __trunctfhf2
43 ; CHECK-SD-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
46 ; CHECK-GI-LABEL: fptrunc_f128_f16:
47 ; CHECK-GI: // %bb.0: // %entry
48 ; CHECK-GI-NEXT: b __trunctfhf2
50 %c = fptrunc fp128 %a to half
54 define float @fptrunc_f128_f32(fp128 %a) {
55 ; CHECK-SD-LABEL: fptrunc_f128_f32:
56 ; CHECK-SD: // %bb.0: // %entry
57 ; CHECK-SD-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
58 ; CHECK-SD-NEXT: .cfi_def_cfa_offset 16
59 ; CHECK-SD-NEXT: .cfi_offset w30, -16
60 ; CHECK-SD-NEXT: bl __trunctfsf2
61 ; CHECK-SD-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
64 ; CHECK-GI-LABEL: fptrunc_f128_f32:
65 ; CHECK-GI: // %bb.0: // %entry
66 ; CHECK-GI-NEXT: b __trunctfsf2
68 %c = fptrunc fp128 %a to float
72 define double @fptrunc_f128_f64(fp128 %a) {
73 ; CHECK-SD-LABEL: fptrunc_f128_f64:
74 ; CHECK-SD: // %bb.0: // %entry
75 ; CHECK-SD-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
76 ; CHECK-SD-NEXT: .cfi_def_cfa_offset 16
77 ; CHECK-SD-NEXT: .cfi_offset w30, -16
78 ; CHECK-SD-NEXT: bl __trunctfdf2
79 ; CHECK-SD-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
82 ; CHECK-GI-LABEL: fptrunc_f128_f64:
83 ; CHECK-GI: // %bb.0: // %entry
84 ; CHECK-GI-NEXT: b __trunctfdf2
86 %c = fptrunc fp128 %a to double
90 define <2 x half> @fptrunc_v2f128_v2f16(<2 x fp128> %a) {
91 ; CHECK-SD-LABEL: fptrunc_v2f128_v2f16:
92 ; CHECK-SD: // %bb.0: // %entry
93 ; CHECK-SD-NEXT: sub sp, sp, #48
94 ; CHECK-SD-NEXT: str x30, [sp, #32] // 8-byte Folded Spill
95 ; CHECK-SD-NEXT: .cfi_def_cfa_offset 48
96 ; CHECK-SD-NEXT: .cfi_offset w30, -16
97 ; CHECK-SD-NEXT: str q0, [sp] // 16-byte Folded Spill
98 ; CHECK-SD-NEXT: mov v0.16b, v1.16b
99 ; CHECK-SD-NEXT: bl __trunctfhf2
100 ; CHECK-SD-NEXT: // kill: def $h0 killed $h0 def $q0
101 ; CHECK-SD-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
102 ; CHECK-SD-NEXT: ldr q0, [sp] // 16-byte Folded Reload
103 ; CHECK-SD-NEXT: bl __trunctfhf2
104 ; CHECK-SD-NEXT: ldr q1, [sp, #16] // 16-byte Folded Reload
105 ; CHECK-SD-NEXT: // kill: def $h0 killed $h0 def $q0
106 ; CHECK-SD-NEXT: ldr x30, [sp, #32] // 8-byte Folded Reload
107 ; CHECK-SD-NEXT: mov v0.h[1], v1.h[0]
108 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
109 ; CHECK-SD-NEXT: add sp, sp, #48
112 ; CHECK-GI-LABEL: fptrunc_v2f128_v2f16:
113 ; CHECK-GI: // %bb.0: // %entry
114 ; CHECK-GI-NEXT: sub sp, sp, #64
115 ; CHECK-GI-NEXT: str x30, [sp, #48] // 8-byte Folded Spill
116 ; CHECK-GI-NEXT: .cfi_def_cfa_offset 64
117 ; CHECK-GI-NEXT: .cfi_offset w30, -16
118 ; CHECK-GI-NEXT: mov v2.d[0], x8
119 ; CHECK-GI-NEXT: str q1, [sp] // 16-byte Folded Spill
120 ; CHECK-GI-NEXT: mov v2.d[1], x8
121 ; CHECK-GI-NEXT: str q2, [sp, #32] // 16-byte Folded Spill
122 ; CHECK-GI-NEXT: bl __trunctfhf2
123 ; CHECK-GI-NEXT: // kill: def $h0 killed $h0 def $q0
124 ; CHECK-GI-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
125 ; CHECK-GI-NEXT: ldr q0, [sp] // 16-byte Folded Reload
126 ; CHECK-GI-NEXT: bl __trunctfhf2
127 ; CHECK-GI-NEXT: // kill: def $h0 killed $h0 def $q0
128 ; CHECK-GI-NEXT: str q0, [sp] // 16-byte Folded Spill
129 ; CHECK-GI-NEXT: ldr q0, [sp, #32] // 16-byte Folded Reload
130 ; CHECK-GI-NEXT: bl __trunctfhf2
131 ; CHECK-GI-NEXT: ldr q0, [sp, #32] // 16-byte Folded Reload
132 ; CHECK-GI-NEXT: bl __trunctfhf2
133 ; CHECK-GI-NEXT: ldp q1, q0, [sp] // 32-byte Folded Reload
134 ; CHECK-GI-NEXT: ldr x30, [sp, #48] // 8-byte Folded Reload
135 ; CHECK-GI-NEXT: mov v0.h[1], v1.h[0]
136 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
137 ; CHECK-GI-NEXT: add sp, sp, #64
140 %c = fptrunc <2 x fp128> %a to <2 x half>
145 define <2 x float> @fptrunc_v2f128_v2f32(<2 x fp128> %a) {
146 ; CHECK-SD-LABEL: fptrunc_v2f128_v2f32:
147 ; CHECK-SD: // %bb.0: // %entry
148 ; CHECK-SD-NEXT: sub sp, sp, #48
149 ; CHECK-SD-NEXT: str x30, [sp, #32] // 8-byte Folded Spill
150 ; CHECK-SD-NEXT: .cfi_def_cfa_offset 48
151 ; CHECK-SD-NEXT: .cfi_offset w30, -16
152 ; CHECK-SD-NEXT: str q0, [sp] // 16-byte Folded Spill
153 ; CHECK-SD-NEXT: mov v0.16b, v1.16b
154 ; CHECK-SD-NEXT: bl __trunctfsf2
155 ; CHECK-SD-NEXT: // kill: def $s0 killed $s0 def $q0
156 ; CHECK-SD-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
157 ; CHECK-SD-NEXT: ldr q0, [sp] // 16-byte Folded Reload
158 ; CHECK-SD-NEXT: bl __trunctfsf2
159 ; CHECK-SD-NEXT: ldr q1, [sp, #16] // 16-byte Folded Reload
160 ; CHECK-SD-NEXT: // kill: def $s0 killed $s0 def $q0
161 ; CHECK-SD-NEXT: ldr x30, [sp, #32] // 8-byte Folded Reload
162 ; CHECK-SD-NEXT: mov v0.s[1], v1.s[0]
163 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
164 ; CHECK-SD-NEXT: add sp, sp, #48
167 ; CHECK-GI-LABEL: fptrunc_v2f128_v2f32:
168 ; CHECK-GI: // %bb.0: // %entry
169 ; CHECK-GI-NEXT: sub sp, sp, #48
170 ; CHECK-GI-NEXT: str x30, [sp, #32] // 8-byte Folded Spill
171 ; CHECK-GI-NEXT: .cfi_def_cfa_offset 48
172 ; CHECK-GI-NEXT: .cfi_offset w30, -16
173 ; CHECK-GI-NEXT: str q1, [sp] // 16-byte Folded Spill
174 ; CHECK-GI-NEXT: bl __trunctfsf2
175 ; CHECK-GI-NEXT: // kill: def $s0 killed $s0 def $q0
176 ; CHECK-GI-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
177 ; CHECK-GI-NEXT: ldr q0, [sp] // 16-byte Folded Reload
178 ; CHECK-GI-NEXT: bl __trunctfsf2
179 ; CHECK-GI-NEXT: ldr q1, [sp, #16] // 16-byte Folded Reload
180 ; CHECK-GI-NEXT: // kill: def $s0 killed $s0 def $q0
181 ; CHECK-GI-NEXT: ldr x30, [sp, #32] // 8-byte Folded Reload
182 ; CHECK-GI-NEXT: mov v1.s[1], v0.s[0]
183 ; CHECK-GI-NEXT: fmov d0, d1
184 ; CHECK-GI-NEXT: add sp, sp, #48
187 %c = fptrunc <2 x fp128> %a to <2 x float>
192 define <2 x double> @fptrunc_v2f128_v2f64(<2 x fp128> %a) {
193 ; CHECK-SD-LABEL: fptrunc_v2f128_v2f64:
194 ; CHECK-SD: // %bb.0: // %entry
195 ; CHECK-SD-NEXT: sub sp, sp, #48
196 ; CHECK-SD-NEXT: str x30, [sp, #32] // 8-byte Folded Spill
197 ; CHECK-SD-NEXT: .cfi_def_cfa_offset 48
198 ; CHECK-SD-NEXT: .cfi_offset w30, -16
199 ; CHECK-SD-NEXT: str q0, [sp] // 16-byte Folded Spill
200 ; CHECK-SD-NEXT: mov v0.16b, v1.16b
201 ; CHECK-SD-NEXT: bl __trunctfdf2
202 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 def $q0
203 ; CHECK-SD-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
204 ; CHECK-SD-NEXT: ldr q0, [sp] // 16-byte Folded Reload
205 ; CHECK-SD-NEXT: bl __trunctfdf2
206 ; CHECK-SD-NEXT: ldr q1, [sp, #16] // 16-byte Folded Reload
207 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 def $q0
208 ; CHECK-SD-NEXT: ldr x30, [sp, #32] // 8-byte Folded Reload
209 ; CHECK-SD-NEXT: mov v0.d[1], v1.d[0]
210 ; CHECK-SD-NEXT: add sp, sp, #48
213 ; CHECK-GI-LABEL: fptrunc_v2f128_v2f64:
214 ; CHECK-GI: // %bb.0: // %entry
215 ; CHECK-GI-NEXT: sub sp, sp, #48
216 ; CHECK-GI-NEXT: str x30, [sp, #32] // 8-byte Folded Spill
217 ; CHECK-GI-NEXT: .cfi_def_cfa_offset 48
218 ; CHECK-GI-NEXT: .cfi_offset w30, -16
219 ; CHECK-GI-NEXT: str q1, [sp] // 16-byte Folded Spill
220 ; CHECK-GI-NEXT: bl __trunctfdf2
221 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 def $q0
222 ; CHECK-GI-NEXT: str q0, [sp, #16] // 16-byte Folded Spill
223 ; CHECK-GI-NEXT: ldr q0, [sp] // 16-byte Folded Reload
224 ; CHECK-GI-NEXT: bl __trunctfdf2
225 ; CHECK-GI-NEXT: ldr q1, [sp, #16] // 16-byte Folded Reload
226 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 def $q0
227 ; CHECK-GI-NEXT: ldr x30, [sp, #32] // 8-byte Folded Reload
228 ; CHECK-GI-NEXT: mov v1.d[1], v0.d[0]
229 ; CHECK-GI-NEXT: mov v0.16b, v1.16b
230 ; CHECK-GI-NEXT: add sp, sp, #48
233 %c = fptrunc <2 x fp128> %a to <2 x double>
237 define <2 x float> @fptrunc_v2f64_v2f32(<2 x double> %a) {
238 ; CHECK-LABEL: fptrunc_v2f64_v2f32:
239 ; CHECK: // %bb.0: // %entry
240 ; CHECK-NEXT: fcvtn v0.2s, v0.2d
243 %c = fptrunc <2 x double> %a to <2 x float>
247 define <3 x float> @fptrunc_v3f64_v3f32(<3 x double> %a) {
248 ; CHECK-SD-LABEL: fptrunc_v3f64_v3f32:
249 ; CHECK-SD: // %bb.0: // %entry
250 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 def $q0
251 ; CHECK-SD-NEXT: // kill: def $d1 killed $d1 def $q1
252 ; CHECK-SD-NEXT: // kill: def $d2 killed $d2 def $q2
253 ; CHECK-SD-NEXT: mov v0.d[1], v1.d[0]
254 ; CHECK-SD-NEXT: fcvtn v0.2s, v0.2d
255 ; CHECK-SD-NEXT: fcvtn2 v0.4s, v2.2d
258 ; CHECK-GI-LABEL: fptrunc_v3f64_v3f32:
259 ; CHECK-GI: // %bb.0: // %entry
260 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 def $q0
261 ; CHECK-GI-NEXT: // kill: def $d1 killed $d1 def $q1
262 ; CHECK-GI-NEXT: fcvt s2, d2
263 ; CHECK-GI-NEXT: mov v0.d[1], v1.d[0]
264 ; CHECK-GI-NEXT: fcvtn v1.2s, v0.2d
265 ; CHECK-GI-NEXT: mov v0.s[0], v1.s[0]
266 ; CHECK-GI-NEXT: mov v0.s[1], v1.s[1]
267 ; CHECK-GI-NEXT: mov v0.s[2], v2.s[0]
270 %c = fptrunc <3 x double> %a to <3 x float>
274 define <4 x float> @fptrunc_v4f64_v4f32(<4 x double> %a) {
275 ; CHECK-LABEL: fptrunc_v4f64_v4f32:
276 ; CHECK: // %bb.0: // %entry
277 ; CHECK-NEXT: fcvtn v0.2s, v0.2d
278 ; CHECK-NEXT: fcvtn2 v0.4s, v1.2d
281 %c = fptrunc <4 x double> %a to <4 x float>
285 define <2 x half> @fptrunc_v2f64_v2f16(<2 x double> %a) {
286 ; CHECK-SD-LABEL: fptrunc_v2f64_v2f16:
287 ; CHECK-SD: // %bb.0: // %entry
288 ; CHECK-SD-NEXT: fcvtxn v0.2s, v0.2d
289 ; CHECK-SD-NEXT: fcvtn v0.4h, v0.4s
292 ; CHECK-GI-LABEL: fptrunc_v2f64_v2f16:
293 ; CHECK-GI: // %bb.0: // %entry
294 ; CHECK-GI-NEXT: mov d1, v0.d[1]
295 ; CHECK-GI-NEXT: fcvt h0, d0
296 ; CHECK-GI-NEXT: fcvt h1, d1
297 ; CHECK-GI-NEXT: mov v0.h[1], v1.h[0]
298 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
301 %c = fptrunc <2 x double> %a to <2 x half>
305 define <3 x half> @fptrunc_v3f64_v3f16(<3 x double> %a) {
306 ; CHECK-SD-LABEL: fptrunc_v3f64_v3f16:
307 ; CHECK-SD: // %bb.0: // %entry
308 ; CHECK-SD-NEXT: fcvt h1, d1
309 ; CHECK-SD-NEXT: fcvt h0, d0
310 ; CHECK-SD-NEXT: mov v0.h[1], v1.h[0]
311 ; CHECK-SD-NEXT: fcvt h1, d2
312 ; CHECK-SD-NEXT: mov v0.h[2], v1.h[0]
313 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 killed $q0
316 ; CHECK-GI-LABEL: fptrunc_v3f64_v3f16:
317 ; CHECK-GI: // %bb.0: // %entry
318 ; CHECK-GI-NEXT: fcvt h0, d0
319 ; CHECK-GI-NEXT: fcvt h1, d1
320 ; CHECK-GI-NEXT: fcvt h2, d2
321 ; CHECK-GI-NEXT: mov v0.h[1], v1.h[0]
322 ; CHECK-GI-NEXT: mov v0.h[2], v2.h[0]
323 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
326 %c = fptrunc <3 x double> %a to <3 x half>
330 define <4 x half> @fptrunc_v4f64_v4f16(<4 x double> %a) {
331 ; CHECK-SD-LABEL: fptrunc_v4f64_v4f16:
332 ; CHECK-SD: // %bb.0: // %entry
333 ; CHECK-SD-NEXT: fcvtxn v0.2s, v0.2d
334 ; CHECK-SD-NEXT: fcvtxn2 v0.4s, v1.2d
335 ; CHECK-SD-NEXT: fcvtn v0.4h, v0.4s
338 ; CHECK-GI-LABEL: fptrunc_v4f64_v4f16:
339 ; CHECK-GI: // %bb.0: // %entry
340 ; CHECK-GI-NEXT: mov d2, v0.d[1]
341 ; CHECK-GI-NEXT: fcvt h0, d0
342 ; CHECK-GI-NEXT: mov d3, v1.d[1]
343 ; CHECK-GI-NEXT: fcvt h1, d1
344 ; CHECK-GI-NEXT: fcvt h2, d2
345 ; CHECK-GI-NEXT: mov v0.h[1], v2.h[0]
346 ; CHECK-GI-NEXT: fcvt h2, d3
347 ; CHECK-GI-NEXT: mov v0.h[2], v1.h[0]
348 ; CHECK-GI-NEXT: mov v0.h[3], v2.h[0]
349 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
352 %c = fptrunc <4 x double> %a to <4 x half>
356 define <2 x half> @fptrunc_v2f32_v2f16(<2 x float> %a) {
357 ; CHECK-SD-LABEL: fptrunc_v2f32_v2f16:
358 ; CHECK-SD: // %bb.0: // %entry
359 ; CHECK-SD-NEXT: // kill: def $d0 killed $d0 def $q0
360 ; CHECK-SD-NEXT: fcvtn v0.4h, v0.4s
363 ; CHECK-GI-LABEL: fptrunc_v2f32_v2f16:
364 ; CHECK-GI: // %bb.0: // %entry
365 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 def $q0
366 ; CHECK-GI-NEXT: mov v1.s[0], v0.s[0]
367 ; CHECK-GI-NEXT: mov v1.s[1], v0.s[1]
368 ; CHECK-GI-NEXT: fcvtn v0.4h, v1.4s
371 %c = fptrunc <2 x float> %a to <2 x half>
375 define <3 x half> @fptrunc_v3f32_v3f16(<3 x float> %a) {
376 ; CHECK-LABEL: fptrunc_v3f32_v3f16:
377 ; CHECK: // %bb.0: // %entry
378 ; CHECK-NEXT: fcvtn v0.4h, v0.4s
381 %c = fptrunc <3 x float> %a to <3 x half>
385 define <4 x half> @fptrunc_v4f32_v4f16(<4 x float> %a) {
386 ; CHECK-LABEL: fptrunc_v4f32_v4f16:
387 ; CHECK: // %bb.0: // %entry
388 ; CHECK-NEXT: fcvtn v0.4h, v0.4s
391 %c = fptrunc <4 x float> %a to <4 x half>
395 define <8 x half> @fptrunc_v8f32_v8f16(<8 x float> %a) {
396 ; CHECK-LABEL: fptrunc_v8f32_v8f16:
397 ; CHECK: // %bb.0: // %entry
398 ; CHECK-NEXT: fcvtn v0.4h, v0.4s
399 ; CHECK-NEXT: fcvtn2 v0.8h, v1.4s
402 %c = fptrunc <8 x float> %a to <8 x half>