1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc < %s | FileCheck %s
4 target triple = "aarch64"
6 ; First some corner cases
7 define <4 x float> @f_v4_s0(<4 x i32> %u) {
8 ; CHECK-LABEL: f_v4_s0:
10 ; CHECK-NEXT: scvtf v0.4s, v0.4s
12 %s = ashr exact <4 x i32> %u, <i32 0, i32 0, i32 0, i32 0>
13 %v = sitofp <4 x i32> %s to <4 x float>
17 define <4 x float> @f_v4_s1(<4 x i32> %u) {
18 ; CHECK-LABEL: f_v4_s1:
20 ; CHECK-NEXT: scvtf v0.4s, v0.4s, #1
22 %s = ashr exact <4 x i32> %u, <i32 1, i32 1, i32 1, i32 1>
23 %v = sitofp <4 x i32> %s to <4 x float>
27 define <4 x float> @f_v4_s24_inexact(<4 x i32> %u) {
28 ; CHECK-LABEL: f_v4_s24_inexact:
30 ; CHECK-NEXT: sshr v0.4s, v0.4s, #24
31 ; CHECK-NEXT: scvtf v0.4s, v0.4s
33 %s = ashr <4 x i32> %u, <i32 24, i32 24, i32 24, i32 24>
34 %v = sitofp <4 x i32> %s to <4 x float>
38 define <4 x float> @f_v4_s31(<4 x i32> %u) {
39 ; CHECK-LABEL: f_v4_s31:
41 ; CHECK-NEXT: cmlt v0.4s, v0.4s, #0
42 ; CHECK-NEXT: scvtf v0.4s, v0.4s
44 %s = ashr <4 x i32> %u, <i32 31, i32 31, i32 31, i32 31>
45 %v = sitofp <4 x i32> %s to <4 x float>
49 ; Common cases for conversion from signed integer to floating point types
50 define <2 x float> @f_v2_s24(<2 x i32> %u) {
51 ; CHECK-LABEL: f_v2_s24:
53 ; CHECK-NEXT: scvtf v0.2s, v0.2s, #24
55 %s = ashr exact <2 x i32> %u, <i32 24, i32 24>
56 %v = sitofp <2 x i32> %s to <2 x float>
60 define <4 x float> @f_v4_s24(<4 x i32> %u) {
61 ; CHECK-LABEL: f_v4_s24:
63 ; CHECK-NEXT: scvtf v0.4s, v0.4s, #24
65 %s = ashr exact <4 x i32> %u, <i32 24, i32 24, i32 24, i32 24>
66 %v = sitofp <4 x i32> %s to <4 x float>
70 ; Check legalisation to <2 x f64> does not get in the way
71 define <8 x double> @d_v8_s64(<8 x i64> %u) {
72 ; CHECK-LABEL: d_v8_s64:
74 ; CHECK-NEXT: scvtf v0.2d, v0.2d, #56
75 ; CHECK-NEXT: scvtf v1.2d, v1.2d, #56
76 ; CHECK-NEXT: scvtf v2.2d, v2.2d, #56
77 ; CHECK-NEXT: scvtf v3.2d, v3.2d, #56
79 %s = ashr exact <8 x i64> %u, <i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56, i64 56>
80 %v = sitofp <8 x i64> %s to <8 x double>
84 define <4 x half> @h_v4_s8(<4 x i16> %u) #0 {
85 ; CHECK-LABEL: h_v4_s8:
87 ; CHECK-NEXT: scvtf v0.4h, v0.4h, #8
89 %s = ashr exact <4 x i16> %u, <i16 8, i16 8, i16 8, i16 8>
90 %v = sitofp <4 x i16> %s to <4 x half>
94 define <8 x half> @h_v8_s8(<8 x i16> %u) #0 {
95 ; CHECK-LABEL: h_v8_s8:
97 ; CHECK-NEXT: scvtf v0.8h, v0.8h, #8
99 %s = ashr exact <8 x i16> %u, <i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8, i16 8>
100 %v = sitofp <8 x i16> %s to <8 x half>
104 ; int-to-fp conversion of element in lane 0 should apply
105 ; cvtf on vector subregister to avoid fpr->gpr trip
106 define float @l0_extract_f_v2s(<2 x i32> %u) {
107 ; CHECK-LABEL: l0_extract_f_v2s:
109 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
110 ; CHECK-NEXT: scvtf s0, s0
112 %i = extractelement <2 x i32> %u, i64 0
113 %f = sitofp i32 %i to float
117 ; cvtf to use ssub for bottom 32-bits from v2i32
118 define float @l0_extract_f_v2u(<2 x i32> %u) {
119 ; CHECK-LABEL: l0_extract_f_v2u:
121 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
122 ; CHECK-NEXT: ucvtf s0, s0
124 %i = extractelement <2 x i32> %u, i64 0
125 %f = uitofp i32 %i to float
129 ; Pattern should only apply when it is known to be lane 0
130 define float @ln_extract_f_v2s(<2 x i32> %u, i64 %n) {
131 ; CHECK-LABEL: ln_extract_f_v2s:
133 ; CHECK-NEXT: sub sp, sp, #16
134 ; CHECK-NEXT: .cfi_def_cfa_offset 16
135 ; CHECK-NEXT: add x8, sp, #8
136 ; CHECK-NEXT: str d0, [sp, #8]
137 ; CHECK-NEXT: bfi x8, x0, #2, #1
138 ; CHECK-NEXT: ldr s0, [x8]
139 ; CHECK-NEXT: scvtf s0, s0
140 ; CHECK-NEXT: add sp, sp, #16
142 %i = extractelement <2 x i32> %u, i64 %n
143 %f = sitofp i32 %i to float
147 ; cvtf to use ssub for bottom 32-bits from v4i32
148 define float @l0_extract_f_v4s(<4 x i32> %u) {
149 ; CHECK-LABEL: l0_extract_f_v4s:
151 ; CHECK-NEXT: scvtf s0, s0
153 %i = extractelement <4 x i32> %u, i64 0
154 %f = sitofp i32 %i to float
158 define float @l0_extract_f_v4u(<4 x i32> %u) {
159 ; CHECK-LABEL: l0_extract_f_v4u:
161 ; CHECK-NEXT: ucvtf s0, s0
163 %i = extractelement <4 x i32> %u, i64 0
164 %f = uitofp i32 %i to float
168 define float @ln_extract_f_v4s(<4 x i32> %u, i64 %n) {
169 ; CHECK-LABEL: ln_extract_f_v4s:
171 ; CHECK-NEXT: sub sp, sp, #16
172 ; CHECK-NEXT: .cfi_def_cfa_offset 16
173 ; CHECK-NEXT: mov x8, sp
174 ; CHECK-NEXT: str q0, [sp]
175 ; CHECK-NEXT: bfi x8, x0, #2, #2
176 ; CHECK-NEXT: ldr s0, [x8]
177 ; CHECK-NEXT: scvtf s0, s0
178 ; CHECK-NEXT: add sp, sp, #16
180 %i = extractelement <4 x i32> %u, i64 %n
181 %f = sitofp i32 %i to float
185 ; cvtf to use dsub for bottom 64-bits from v2i64
186 define double @l0_extract_d_v2s(<2 x i64> %u) {
187 ; CHECK-LABEL: l0_extract_d_v2s:
189 ; CHECK-NEXT: scvtf d0, d0
191 %i = extractelement <2 x i64> %u, i64 0
192 %f = sitofp i64 %i to double
196 define double @l0_extract_d_v2u(<2 x i64> %u) {
197 ; CHECK-LABEL: l0_extract_d_v2u:
199 ; CHECK-NEXT: ucvtf d0, d0
201 %i = extractelement <2 x i64> %u, i64 0
202 %f = uitofp i64 %i to double
206 define double @ln_extract_d_v2s(<2 x i64> %u, i64 %n) {
207 ; CHECK-LABEL: ln_extract_d_v2s:
209 ; CHECK-NEXT: sub sp, sp, #16
210 ; CHECK-NEXT: .cfi_def_cfa_offset 16
211 ; CHECK-NEXT: mov x8, sp
212 ; CHECK-NEXT: str q0, [sp]
213 ; CHECK-NEXT: bfi x8, x0, #3, #1
214 ; CHECK-NEXT: ldr d0, [x8]
215 ; CHECK-NEXT: scvtf d0, d0
216 ; CHECK-NEXT: add sp, sp, #16
218 %i = extractelement <2 x i64> %u, i64 %n
219 %f = sitofp i64 %i to double
223 ; (fullfp16) cvtf to use hsub for bottom 16-bits from v8i16
224 define half @l0_extract_h_v8s(<8 x i16> %u) #0 {
225 ; CHECK-LABEL: l0_extract_h_v8s:
227 ; CHECK-NEXT: scvtf h0, h0
229 %i = extractelement <8 x i16> %u, i32 0
230 %f = sitofp i16 %i to half
234 define half @l0_extract_h_v8u(<8 x i16> %u) #0 {
235 ; CHECK-LABEL: l0_extract_h_v8u:
237 ; CHECK-NEXT: ucvtf h0, h0
239 %i = extractelement <8 x i16> %u, i32 0
240 %f = uitofp i16 %i to half
244 define half @ln_extract_h_v8u(<8 x i16> %u, i32 %n) #0 {
245 ; CHECK-LABEL: ln_extract_h_v8u:
247 ; CHECK-NEXT: sub sp, sp, #16
248 ; CHECK-NEXT: .cfi_def_cfa_offset 16
249 ; CHECK-NEXT: mov x8, sp
250 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
251 ; CHECK-NEXT: str q0, [sp]
252 ; CHECK-NEXT: bfi x8, x0, #1, #3
253 ; CHECK-NEXT: ldrh w8, [x8]
254 ; CHECK-NEXT: ucvtf h0, w8
255 ; CHECK-NEXT: add sp, sp, #16
257 %i = extractelement <8 x i16> %u, i32 %n
258 %f = uitofp i16 %i to half
262 attributes #0 = { "target-features"="+fullfp16"}