1 ; RUN: llc -aarch64-sve-vector-bits-min=128 -asm-verbose=0 < %s | FileCheck %s -check-prefix=NO_SVE
2 ; RUN: llc -aarch64-sve-vector-bits-min=256 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256
3 ; RUN: llc -aarch64-sve-vector-bits-min=384 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256
4 ; RUN: llc -aarch64-sve-vector-bits-min=512 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512
5 ; RUN: llc -aarch64-sve-vector-bits-min=640 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512
6 ; RUN: llc -aarch64-sve-vector-bits-min=768 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512
7 ; RUN: llc -aarch64-sve-vector-bits-min=896 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512
8 ; RUN: llc -aarch64-sve-vector-bits-min=1024 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
9 ; RUN: llc -aarch64-sve-vector-bits-min=1152 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
10 ; RUN: llc -aarch64-sve-vector-bits-min=1280 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
11 ; RUN: llc -aarch64-sve-vector-bits-min=1408 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
12 ; RUN: llc -aarch64-sve-vector-bits-min=1536 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
13 ; RUN: llc -aarch64-sve-vector-bits-min=1664 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
14 ; RUN: llc -aarch64-sve-vector-bits-min=1792 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
15 ; RUN: llc -aarch64-sve-vector-bits-min=1920 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024
16 ; RUN: llc -aarch64-sve-vector-bits-min=2048 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_256,VBITS_GE_512,VBITS_GE_1024,VBITS_GE_2048
18 target triple = "aarch64-unknown-linux-gnu"
20 ; Don't use SVE when its registers are no bigger than NEON.
27 ; Don't use SVE for 64-bit vectors.
28 define half @extractelement_v4f16(<4 x half> %op1) #0 {
29 ; CHECK-LABEL: extractelement_v4f16:
30 ; CHECK: mov h0, v0.h[3]
32 %r = extractelement <4 x half> %op1, i64 3
36 ; Don't use SVE for 128-bit vectors.
37 define half @extractelement_v8f16(<8 x half> %op1) #0 {
38 ; CHECK-LABEL: extractelement_v8f16:
39 ; CHECK: mov h0, v0.h[7]
41 %r = extractelement <8 x half> %op1, i64 7
45 define half @extractelement_v16f16(<16 x half>* %a) #0 {
46 ; CHECK-LABEL: extractelement_v16f16:
47 ; VBITS_GE_256: ptrue p0.h, vl16
48 ; VBITS_GE_256-NEXT: ld1h { z0.h }, p0/z, [x0]
49 ; VBITS_GE_256-NEXT: mov z0.h, z0.h[15]
50 ; VBITS_GE_256-NEXT: ret
51 %op1 = load <16 x half>, <16 x half>* %a
52 %r = extractelement <16 x half> %op1, i64 15
56 define half @extractelement_v32f16(<32 x half>* %a) #0 {
57 ; CHECK-LABEL: extractelement_v32f16:
58 ; VBITS_GE_512: 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: ret
62 %op1 = load <32 x half>, <32 x half>* %a
63 %r = extractelement <32 x half> %op1, i64 31
67 define half @extractelement_v64f16(<64 x half>* %a) #0 {
68 ; CHECK-LABEL: extractelement_v64f16:
69 ; VBITS_GE_1024: ptrue p0.h, vl64
70 ; VBITS_GE_1024-NEXT: ld1h { z0.h }, p0/z, [x0]
71 ; VBITS_GE_1024-NEXT: mov w8, #63
72 ; VBITS_GE_1024-NEXT: whilels p0.h, xzr, x8
73 ; VBITS_GE_1024-NEXT: lastb h0, p0, z0.h
74 ; VBITS_GE_1024-NEXT: ret
75 %op1 = load <64 x half>, <64 x half>* %a
76 %r = extractelement <64 x half> %op1, i64 63
80 define half @extractelement_v128f16(<128 x half>* %a) #0 {
81 ; CHECK-LABEL: extractelement_v128f16:
82 ; VBITS_GE_2048: ptrue p0.h, vl128
83 ; VBITS_GE_2048-NEXT: ld1h { z0.h }, p0/z, [x0]
84 ; VBITS_GE_2048-NEXT: mov w8, #127
85 ; VBITS_GE_2048-NEXT: whilels p0.h, xzr, x8
86 ; VBITS_GE_2048-NEXT: lastb h0, p0, z0.h
87 ; VBITS_GE_2048-NEXT: ret
88 %op1 = load <128 x half>, <128 x half>* %a
89 %r = extractelement <128 x half> %op1, i64 127
93 ; Don't use SVE for 64-bit vectors.
94 define float @extractelement_v2f32(<2 x float> %op1) #0 {
95 ; CHECK-LABEL: extractelement_v2f32:
96 ; CHECK: mov s0, v0.s[1]
98 %r = extractelement <2 x float> %op1, i64 1
102 ; Don't use SVE for 128-bit vectors.
103 define float @extractelement_v4f32(<4 x float> %op1) #0 {
104 ; CHECK-LABEL: extractelement_v4f32:
105 ; CHECK: mov s0, v0.s[3]
107 %r = extractelement <4 x float> %op1, i64 3
111 define float @extractelement_v8f32(<8 x float>* %a) #0 {
112 ; CHECK-LABEL: extractelement_v8f32:
113 ; VBITS_GE_256: ptrue p0.s, vl8
114 ; VBITS_GE_256-NEXT: ld1w { z0.s }, p0/z, [x0]
115 ; VBITS_GE_256-NEXT: mov z0.s, z0.s[7]
116 ; VBITS_GE_256-NEXT: ret
117 %op1 = load <8 x float>, <8 x float>* %a
118 %r = extractelement <8 x float> %op1, i64 7
122 define float @extractelement_v16f32(<16 x float>* %a) #0 {
123 ; CHECK-LABEL: extractelement_v16f32:
124 ; VBITS_GE_512: ptrue p0.s, vl16
125 ; VBITS_GE_512-NEXT: ld1w { z0.s }, p0/z, [x0]
126 ; VBITS_GE_512-NEXT: mov z0.s, z0.s[15]
127 ; VBITS_GE_512-NEXT: ret
128 %op1 = load <16 x float>, <16 x float>* %a
129 %r = extractelement <16 x float> %op1, i64 15
133 define float @extractelement_v32f32(<32 x float>* %a) #0 {
134 ; CHECK-LABEL: extractelement_v32f32:
135 ; VBITS_GE_1024: ptrue p0.s, vl32
136 ; VBITS_GE_1024-NEXT: ld1w { z0.s }, p0/z, [x0]
137 ; VBITS_GE_1024-NEXT: mov w8, #31
138 ; VBITS_GE_1024-NEXT: whilels p0.s, xzr, x8
139 ; VBITS_GE_1024-NEXT: lastb s0, p0, z0.s
140 ; VBITS_GE_1024-NEXT: ret
141 %op1 = load <32 x float>, <32 x float>* %a
142 %r = extractelement <32 x float> %op1, i64 31
146 define float @extractelement_v64f32(<64 x float>* %a) #0 {
147 ; CHECK-LABEL: extractelement_v64f32:
148 ; VBITS_GE_2048: ptrue p0.s, vl64
149 ; VBITS_GE_2048-NEXT: ld1w { z0.s }, p0/z, [x0]
150 ; VBITS_GE_2048-NEXT: mov w8, #63
151 ; VBITS_GE_2048-NEXT: whilels p0.s, xzr, x8
152 ; VBITS_GE_2048-NEXT: lastb s0, p0, z0.s
153 ; VBITS_GE_2048-NEXT: ret
154 %op1 = load <64 x float>, <64 x float>* %a
155 %r = extractelement <64 x float> %op1, i64 63
159 ; Don't use SVE for 64-bit vectors.
160 define double @extractelement_v1f64(<1 x double> %op1) #0 {
161 ; CHECK-LABEL: extractelement_v1f64:
163 %r = extractelement <1 x double> %op1, i64 0
167 ; Don't use SVE for 128-bit vectors.
168 define double @extractelement_v2f64(<2 x double> %op1) #0 {
169 ; CHECK-LABEL: extractelement_v2f64:
170 ; CHECK: mov d0, v0.d[1]
172 %r = extractelement <2 x double> %op1, i64 1
176 define double @extractelement_v4f64(<4 x double>* %a) #0 {
177 ; CHECK-LABEL: extractelement_v4f64:
178 ; VBITS_GE_256: ptrue p0.d, vl4
179 ; VBITS_GE_256-NEXT: ld1d { z0.d }, p0/z, [x0]
180 ; VBITS_GE_256-NEXT: mov z0.d, z0.d[3]
181 ; VBITS_GE_256-NEXT: ret
182 %op1 = load <4 x double>, <4 x double>* %a
183 %r = extractelement <4 x double> %op1, i64 3
187 define double @extractelement_v8f64(<8 x double>* %a) #0 {
188 ; CHECK-LABEL: extractelement_v8f64:
189 ; VBITS_GE_512: ptrue p0.d, vl8
190 ; VBITS_GE_512-NEXT: ld1d { z0.d }, p0/z, [x0]
191 ; VBITS_GE_512-NEXT: mov z0.d, z0.d[7]
192 ; VBITS_GE_512-NEXT: ret
193 %op1 = load <8 x double>, <8 x double>* %a
194 %r = extractelement <8 x double> %op1, i64 7
198 define double @extractelement_v16f64(<16 x double>* %a) #0 {
199 ; CHECK-LABEL: extractelement_v16f64:
200 ; VBITS_GE_1024: ptrue p0.d, vl16
201 ; VBITS_GE_1024-NEXT: ld1d { z0.d }, p0/z, [x0]
202 ; VBITS_GE_1024-NEXT: mov w8, #15
203 ; VBITS_GE_1024-NEXT: whilels p0.d, xzr, x8
204 ; VBITS_GE_1024-NEXT: lastb d0, p0, z0.d
205 ; VBITS_GE_1024-NEXT: ret
206 %op1 = load <16 x double>, <16 x double>* %a
207 %r = extractelement <16 x double> %op1, i64 15
211 define double @extractelement_v32f64(<32 x double>* %a) #0 {
212 ; CHECK-LABEL: extractelement_v32f64:
213 ; VBITS_GE_2048: ptrue p0.d, vl32
214 ; VBITS_GE_2048-NEXT: ld1d { z0.d }, p0/z, [x0]
215 ; VBITS_GE_2048-NEXT: mov w8, #31
216 ; VBITS_GE_2048-NEXT: whilels p0.d, xzr, x8
217 ; VBITS_GE_2048-NEXT: lastb d0, p0, z0.d
218 ; VBITS_GE_2048-NEXT: ret
219 %op1 = load <32 x double>, <32 x double>* %a
220 %r = extractelement <32 x double> %op1, i64 31
224 attributes #0 = { "target-features"="+sve" }