1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256
3 ; RUN: llc -aarch64-sve-vector-bits-min=512 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
4 ; RUN: llc -aarch64-sve-vector-bits-min=2048 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
6 target triple = "aarch64-unknown-linux-gnu"
12 ; Don't use SVE for 64-bit vectors.
13 define half @extractelement_v4f16(<4 x half> %op1) vscale_range(2,0) #0 {
14 ; CHECK-LABEL: extractelement_v4f16:
16 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
17 ; CHECK-NEXT: mov h0, v0.h[3]
19 %r = extractelement <4 x half> %op1, i64 3
23 ; Don't use SVE for 128-bit vectors.
24 define half @extractelement_v8f16(<8 x half> %op1) vscale_range(2,0) #0 {
25 ; CHECK-LABEL: extractelement_v8f16:
27 ; CHECK-NEXT: mov h0, v0.h[7]
29 %r = extractelement <8 x half> %op1, i64 7
33 define half @extractelement_v16f16(ptr %a) vscale_range(2,0) #0 {
34 ; CHECK-LABEL: extractelement_v16f16:
36 ; CHECK-NEXT: ptrue p0.h, vl16
37 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
38 ; CHECK-NEXT: mov z0.h, z0.h[15]
39 ; CHECK-NEXT: // kill: def $h0 killed $h0 killed $z0
41 %op1 = load <16 x half>, ptr %a
42 %r = extractelement <16 x half> %op1, i64 15
46 define half @extractelement_v32f16(ptr %a) #0 {
47 ; VBITS_GE_256-LABEL: extractelement_v32f16:
48 ; VBITS_GE_256: // %bb.0:
49 ; VBITS_GE_256-NEXT: ptrue p0.h, vl16
50 ; VBITS_GE_256-NEXT: mov x8, #16 // =0x10
51 ; VBITS_GE_256-NEXT: ld1h { z0.h }, p0/z, [x0, x8, lsl #1]
52 ; VBITS_GE_256-NEXT: mov z0.h, z0.h[15]
53 ; VBITS_GE_256-NEXT: // kill: def $h0 killed $h0 killed $z0
54 ; VBITS_GE_256-NEXT: ret
56 ; VBITS_GE_512-LABEL: extractelement_v32f16:
57 ; VBITS_GE_512: // %bb.0:
58 ; VBITS_GE_512-NEXT: ptrue p0.h, vl32
59 ; VBITS_GE_512-NEXT: ld1h { z0.h }, p0/z, [x0]
60 ; VBITS_GE_512-NEXT: mov z0.h, z0.h[31]
61 ; VBITS_GE_512-NEXT: // kill: def $h0 killed $h0 killed $z0
62 ; VBITS_GE_512-NEXT: ret
63 %op1 = load <32 x half>, ptr %a
64 %r = extractelement <32 x half> %op1, i64 31
68 define half @extractelement_v64f16(ptr %a) vscale_range(8,0) #0 {
69 ; CHECK-LABEL: extractelement_v64f16:
71 ; CHECK-NEXT: ptrue p0.h, vl64
72 ; CHECK-NEXT: mov w8, #63 // =0x3f
73 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
74 ; CHECK-NEXT: whilels p0.h, xzr, x8
75 ; CHECK-NEXT: lastb h0, p0, z0.h
77 %op1 = load <64 x half>, ptr %a
78 %r = extractelement <64 x half> %op1, i64 63
82 define half @extractelement_v128f16(ptr %a) vscale_range(16,0) #0 {
83 ; CHECK-LABEL: extractelement_v128f16:
85 ; CHECK-NEXT: ptrue p0.h, vl128
86 ; CHECK-NEXT: mov w8, #127 // =0x7f
87 ; CHECK-NEXT: ld1h { z0.h }, p0/z, [x0]
88 ; CHECK-NEXT: whilels p0.h, xzr, x8
89 ; CHECK-NEXT: lastb h0, p0, z0.h
91 %op1 = load <128 x half>, ptr %a
92 %r = extractelement <128 x half> %op1, i64 127
96 ; Don't use SVE for 64-bit vectors.
97 define float @extractelement_v2f32(<2 x float> %op1) vscale_range(2,0) #0 {
98 ; CHECK-LABEL: extractelement_v2f32:
100 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
101 ; CHECK-NEXT: mov s0, v0.s[1]
103 %r = extractelement <2 x float> %op1, i64 1
107 ; Don't use SVE for 128-bit vectors.
108 define float @extractelement_v4f32(<4 x float> %op1) vscale_range(2,0) #0 {
109 ; CHECK-LABEL: extractelement_v4f32:
111 ; CHECK-NEXT: mov s0, v0.s[3]
113 %r = extractelement <4 x float> %op1, i64 3
117 define float @extractelement_v8f32(ptr %a) vscale_range(2,0) #0 {
118 ; CHECK-LABEL: extractelement_v8f32:
120 ; CHECK-NEXT: ptrue p0.s, vl8
121 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
122 ; CHECK-NEXT: mov z0.s, z0.s[7]
123 ; CHECK-NEXT: // kill: def $s0 killed $s0 killed $z0
125 %op1 = load <8 x float>, ptr %a
126 %r = extractelement <8 x float> %op1, i64 7
130 define float @extractelement_v16f32(ptr %a) #0 {
131 ; VBITS_GE_256-LABEL: extractelement_v16f32:
132 ; VBITS_GE_256: // %bb.0:
133 ; VBITS_GE_256-NEXT: ptrue p0.s, vl8
134 ; VBITS_GE_256-NEXT: mov x8, #8 // =0x8
135 ; VBITS_GE_256-NEXT: ld1w { z0.s }, p0/z, [x0, x8, lsl #2]
136 ; VBITS_GE_256-NEXT: mov z0.s, z0.s[7]
137 ; VBITS_GE_256-NEXT: // kill: def $s0 killed $s0 killed $z0
138 ; VBITS_GE_256-NEXT: ret
140 ; VBITS_GE_512-LABEL: extractelement_v16f32:
141 ; VBITS_GE_512: // %bb.0:
142 ; VBITS_GE_512-NEXT: ptrue p0.s, vl16
143 ; VBITS_GE_512-NEXT: ld1w { z0.s }, p0/z, [x0]
144 ; VBITS_GE_512-NEXT: mov z0.s, z0.s[15]
145 ; VBITS_GE_512-NEXT: // kill: def $s0 killed $s0 killed $z0
146 ; VBITS_GE_512-NEXT: ret
147 %op1 = load <16 x float>, ptr %a
148 %r = extractelement <16 x float> %op1, i64 15
152 define float @extractelement_v32f32(ptr %a) vscale_range(8,0) #0 {
153 ; CHECK-LABEL: extractelement_v32f32:
155 ; CHECK-NEXT: ptrue p0.s, vl32
156 ; CHECK-NEXT: mov w8, #31 // =0x1f
157 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
158 ; CHECK-NEXT: whilels p0.s, xzr, x8
159 ; CHECK-NEXT: lastb s0, p0, z0.s
161 %op1 = load <32 x float>, ptr %a
162 %r = extractelement <32 x float> %op1, i64 31
166 define float @extractelement_v64f32(ptr %a) vscale_range(16,0) #0 {
167 ; CHECK-LABEL: extractelement_v64f32:
169 ; CHECK-NEXT: ptrue p0.s, vl64
170 ; CHECK-NEXT: mov w8, #63 // =0x3f
171 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0]
172 ; CHECK-NEXT: whilels p0.s, xzr, x8
173 ; CHECK-NEXT: lastb s0, p0, z0.s
175 %op1 = load <64 x float>, ptr %a
176 %r = extractelement <64 x float> %op1, i64 63
180 ; Don't use SVE for 64-bit vectors.
181 define double @extractelement_v1f64(<1 x double> %op1) vscale_range(2,0) #0 {
182 ; CHECK-LABEL: extractelement_v1f64:
185 %r = extractelement <1 x double> %op1, i64 0
189 ; Don't use SVE for 128-bit vectors.
190 define double @extractelement_v2f64(<2 x double> %op1) vscale_range(2,0) #0 {
191 ; CHECK-LABEL: extractelement_v2f64:
193 ; CHECK-NEXT: mov d0, v0.d[1]
195 %r = extractelement <2 x double> %op1, i64 1
199 define double @extractelement_v4f64(ptr %a) vscale_range(2,0) #0 {
200 ; CHECK-LABEL: extractelement_v4f64:
202 ; CHECK-NEXT: ptrue p0.d, vl4
203 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
204 ; CHECK-NEXT: mov z0.d, z0.d[3]
205 ; CHECK-NEXT: // kill: def $d0 killed $d0 killed $z0
207 %op1 = load <4 x double>, ptr %a
208 %r = extractelement <4 x double> %op1, i64 3
212 define double @extractelement_v8f64(ptr %a) #0 {
213 ; VBITS_GE_256-LABEL: extractelement_v8f64:
214 ; VBITS_GE_256: // %bb.0:
215 ; VBITS_GE_256-NEXT: ptrue p0.d, vl4
216 ; VBITS_GE_256-NEXT: mov x8, #4 // =0x4
217 ; VBITS_GE_256-NEXT: ld1d { z0.d }, p0/z, [x0, x8, lsl #3]
218 ; VBITS_GE_256-NEXT: mov z0.d, z0.d[3]
219 ; VBITS_GE_256-NEXT: // kill: def $d0 killed $d0 killed $z0
220 ; VBITS_GE_256-NEXT: ret
222 ; VBITS_GE_512-LABEL: extractelement_v8f64:
223 ; VBITS_GE_512: // %bb.0:
224 ; VBITS_GE_512-NEXT: ptrue p0.d, vl8
225 ; VBITS_GE_512-NEXT: ld1d { z0.d }, p0/z, [x0]
226 ; VBITS_GE_512-NEXT: mov z0.d, z0.d[7]
227 ; VBITS_GE_512-NEXT: // kill: def $d0 killed $d0 killed $z0
228 ; VBITS_GE_512-NEXT: ret
229 %op1 = load <8 x double>, ptr %a
230 %r = extractelement <8 x double> %op1, i64 7
234 define double @extractelement_v16f64(ptr %a) vscale_range(8,0) #0 {
235 ; CHECK-LABEL: extractelement_v16f64:
237 ; CHECK-NEXT: ptrue p0.d, vl16
238 ; CHECK-NEXT: mov w8, #15 // =0xf
239 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
240 ; CHECK-NEXT: whilels p0.d, xzr, x8
241 ; CHECK-NEXT: lastb d0, p0, z0.d
243 %op1 = load <16 x double>, ptr %a
244 %r = extractelement <16 x double> %op1, i64 15
248 define double @extractelement_v32f64(ptr %a) vscale_range(16,0) #0 {
249 ; CHECK-LABEL: extractelement_v32f64:
251 ; CHECK-NEXT: ptrue p0.d, vl32
252 ; CHECK-NEXT: mov w8, #31 // =0x1f
253 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0]
254 ; CHECK-NEXT: whilels p0.d, xzr, x8
255 ; CHECK-NEXT: lastb d0, p0, z0.d
257 %op1 = load <32 x double>, ptr %a
258 %r = extractelement <32 x double> %op1, i64 31
262 attributes #0 = { "target-features"="+sve" }