1 ; RUN: llc -aarch64-sve-vector-bits-min=128 < %s | FileCheck %s -D#VBYTES=16 -check-prefix=NO_SVE
2 ; RUN: llc -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s -D#VBYTES=32 -check-prefixes=CHECK,VBITS_EQ_256
3 ; RUN: llc -aarch64-sve-vector-bits-min=384 < %s | FileCheck %s -D#VBYTES=32 -check-prefixes=CHECK
4 ; RUN: llc -aarch64-sve-vector-bits-min=512 < %s | FileCheck %s -D#VBYTES=64 -check-prefixes=CHECK,VBITS_GE_512
5 ; RUN: llc -aarch64-sve-vector-bits-min=640 < %s | FileCheck %s -D#VBYTES=64 -check-prefixes=CHECK,VBITS_GE_512
6 ; RUN: llc -aarch64-sve-vector-bits-min=768 < %s | FileCheck %s -D#VBYTES=64 -check-prefixes=CHECK,VBITS_GE_512
7 ; RUN: llc -aarch64-sve-vector-bits-min=896 < %s | FileCheck %s -D#VBYTES=64 -check-prefixes=CHECK,VBITS_GE_512
8 ; RUN: llc -aarch64-sve-vector-bits-min=1024 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
9 ; RUN: llc -aarch64-sve-vector-bits-min=1152 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
10 ; RUN: llc -aarch64-sve-vector-bits-min=1280 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
11 ; RUN: llc -aarch64-sve-vector-bits-min=1408 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
12 ; RUN: llc -aarch64-sve-vector-bits-min=1536 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
13 ; RUN: llc -aarch64-sve-vector-bits-min=1664 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
14 ; RUN: llc -aarch64-sve-vector-bits-min=1792 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
15 ; RUN: llc -aarch64-sve-vector-bits-min=1920 < %s | FileCheck %s -D#VBYTES=128 -check-prefixes=CHECK,VBITS_GE_1024,VBITS_GE_512
16 ; RUN: llc -aarch64-sve-vector-bits-min=2048 < %s | FileCheck %s -D#VBYTES=256 -check-prefixes=CHECK,VBITS_GE_2048,VBITS_GE_1024,VBITS_GE_512
18 target triple = "aarch64-unknown-linux-gnu"
20 ; Don't use SVE when its registers are no bigger than NEON.
23 define void @store_trunc_v2i64i8(<2 x i64>* %ap, <2 x i8>* %dest) #0 {
24 ; CHECK-LABEL: store_trunc_v2i64i8
25 ; CHECK: ldr q[[Q0:[0-9]+]], [x0]
26 ; CHECK: ptrue p[[P0:[0-9]+]].d, vl2
27 ; CHECK-NEXT: st1b { z[[Q0]].d }, p[[P0]], [x1]
29 %a = load <2 x i64>, <2 x i64>* %ap
30 %val = trunc <2 x i64> %a to <2 x i8>
31 store <2 x i8> %val, <2 x i8>* %dest
35 define void @store_trunc_v4i64i8(<4 x i64>* %ap, <4 x i8>* %dest) #0 {
36 ; CHECK-LABEL: store_trunc_v4i64i8
37 ; CHECK: ptrue p[[P0:[0-9]+]].d, vl4
38 ; CHECK-NEXT: ld1d { [[Z0:z[0-9]+]].d }, p0/z, [x0]
39 ; CHECK-NEXT: st1b { z[[Q0]].d }, p[[P0]], [x1]
41 %a = load <4 x i64>, <4 x i64>* %ap
42 %val = trunc <4 x i64> %a to <4 x i8>
43 store <4 x i8> %val, <4 x i8>* %dest
47 define void @store_trunc_v8i64i8(<8 x i64>* %ap, <8 x i8>* %dest) #0 {
48 ; CHECK-LABEL: store_trunc_v8i64i8:
49 ; VBITS_GE_512: ptrue p[[P0:[0-9]+]].d, vl8
50 ; VBITS_GE_512-NEXT: ld1d { [[Z0:z[0-9]+]].d }, p0/z, [x0]
51 ; VBITS_GE_512-NEXT: st1b { [[Z0]].d }, p[[P0]], [x1]
52 ; VBITS_GE_512-NEXT: ret
54 ; Ensure sensible type legalisation
55 ; VBITS_EQ_256-DAG: ptrue [[PG1:p[0-9]+]].d, vl4
56 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #4
57 ; VBITS_EQ_256-DAG: ld1d { [[DWORDS_LO:z[0-9]+]].d }, [[PG1]]/z, [x0]
58 ; VBITS_EQ_256-DAG: ld1d { [[DWORDS_HI:z[0-9]+]].d }, [[PG1]]/z, [x0, x[[NUMELTS]], lsl #3]
59 ; VBITS_EQ_256-DAG: ptrue [[PG2:p[0-9]+]].s, vl4
60 ; VBITS_EQ_256-DAG: uzp1 [[WORDS_LO:z[0-9]+]].s, [[DWORDS_LO]].s, [[DWORDS_LO]].s
61 ; VBITS_EQ_256-DAG: uzp1 [[WORDS_HI:z[0-9]+]].s, [[DWORDS_HI]].s, [[DWORDS_HI]].s
62 ; VBITS_EQ_256-DAG: splice [[WORDS:z[0-9]+]].s, [[PG2]], [[WORDS_LO]].s, [[WORDS_HI]].s
63 ; VBITS_EQ_256-DAG: ptrue [[PG3:p[0-9]+]].s, vl8
64 ; VBITS_EQ_256-NEXT: st1b { [[WORDS]].s }, [[PG3]], [x1]
65 ; VBITS_EQ_256-NEXT: ret
66 %a = load <8 x i64>, <8 x i64>* %ap
67 %val = trunc <8 x i64> %a to <8 x i8>
68 store <8 x i8> %val, <8 x i8>* %dest
72 define void @store_trunc_v16i64i8(<16 x i64>* %ap, <16 x i8>* %dest) #0 {
73 ; CHECK-LABEL: store_trunc_v16i64i8:
74 ; VBITS_GE_1024: ptrue p[[P0:[0-9]+]].d, vl16
75 ; VBITS_GE_1024-NEXT: ld1d { [[Z0:z[0-9]+]].d }, p0/z, [x0]
76 ; VBITS_GE_1024-NEXT: st1b { [[Z0]].d }, p[[P0]], [x1]
77 ; VBITS_GE_1024-NEXT: ret
78 %a = load <16 x i64>, <16 x i64>* %ap
79 %val = trunc <16 x i64> %a to <16 x i8>
80 store <16 x i8> %val, <16 x i8>* %dest
84 define void @store_trunc_v32i64i8(<32 x i64>* %ap, <32 x i8>* %dest) #0 {
85 ; CHECK-LABEL: store_trunc_v32i64i8:
86 ; VBITS_GE_2048: ptrue p[[P0:[0-9]+]].d, vl32
87 ; VBITS_GE_2048-NEXT: ld1d { [[Z0:z[0-9]+]].d }, p0/z, [x0]
88 ; VBITS_GE_2048-NEXT: st1b { [[Z0]].d }, p[[P0]], [x1]
89 ; VBITS_GE_2048-NEXT: ret
90 %a = load <32 x i64>, <32 x i64>* %ap
91 %val = trunc <32 x i64> %a to <32 x i8>
92 store <32 x i8> %val, <32 x i8>* %dest
96 define void @store_trunc_v8i64i16(<8 x i64>* %ap, <8 x i16>* %dest) #0 {
97 ; CHECK-LABEL: store_trunc_v8i64i16:
98 ; VBITS_GE_512: ptrue p[[P0:[0-9]+]].d, vl8
99 ; VBITS_GE_512-NEXT: ld1d { [[Z0:z[0-9]+]].d }, p0/z, [x0]
100 ; VBITS_GE_512-NEXT: st1h { [[Z0]].d }, p[[P0]], [x1]
101 ; VBITS_GE_512-NEXT: ret
103 ; Ensure sensible type legalisation.
104 ; Currently does not use the truncating store
105 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].d, vl4
106 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #4
107 ; VBITS_EQ_256-DAG: ld1d { [[DWORDS_LO:z[0-9]+]].d }, [[PG]]/z, [x0]
108 ; VBITS_EQ_256-DAG: ld1d { [[DWORDS_HI:z[0-9]+]].d }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #3]
109 ; VBITS_EQ_256-DAG: uzp1 [[WORDS_LO:z[0-9]+]].s, [[DWORDS_LO]].s, [[DWORDS_LO]].s
110 ; VBITS_EQ_256-DAG: uzp1 [[WORDS_HI:z[0-9]+]].s, [[DWORDS_HI]].s, [[DWORDS_HI]].s
111 ; VBITS_EQ_256-DAG: uzp1 z[[HALFS_LO:[0-9]+]].h, [[WORDS_LO]].h, [[WORDS_LO]].h
112 ; VBITS_EQ_256-DAG: uzp1 z[[HALFS_HI:[0-9]+]].h, [[WORDS_HI]].h, [[WORDS_HI]].h
113 ; VBITS_EQ_256-NEXT: mov v[[HALFS_LO]].d[1], v[[HALFS_HI]].d[0]
114 ; VBITS_EQ_256-NEXT: str q[[HALFS_LO]], [x1]
115 ; VBITS_EQ_256-NEXT: ret
116 %a = load <8 x i64>, <8 x i64>* %ap
117 %val = trunc <8 x i64> %a to <8 x i16>
118 store <8 x i16> %val, <8 x i16>* %dest
122 define void @store_trunc_v8i64i32(<8 x i64>* %ap, <8 x i32>* %dest) #0 {
123 ; CHECK-LABEL: store_trunc_v8i64i32:
124 ; VBITS_GE_512: ptrue p[[P0:[0-9]+]].d, vl8
125 ; VBITS_GE_512-NEXT: ld1d { [[Z0:z[0-9]+]].d }, p0/z, [x0]
126 ; VBITS_GE_512-NEXT: st1w { [[Z0]].d }, p[[P0]], [x1]
127 ; VBITS_GE_512-NEXT: ret
129 ; Ensure sensible type legalisation
130 ; VBITS_EQ_256-DAG: ptrue [[PG1:p[0-9]+]].d, vl4
131 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #4
132 ; VBITS_EQ_256-DAG: ld1d { [[DWORDS_LO:z[0-9]+]].d }, [[PG1]]/z, [x0]
133 ; VBITS_EQ_256-DAG: ld1d { [[DWORDS_HI:z[0-9]+]].d }, [[PG1]]/z, [x0, x[[NUMELTS]], lsl #3]
134 ; VBITS_EQ_256-DAG: ptrue [[PG2:p[0-9]+]].s, vl4
135 ; VBITS_EQ_256-DAG: uzp1 [[WORDS_LO:z[0-9]+]].s, [[DWORDS_LO]].s, [[DWORDS_LO]].s
136 ; VBITS_EQ_256-DAG: uzp1 [[WORDS_HI:z[0-9]+]].s, [[DWORDS_HI]].s, [[DWORDS_HI]].s
137 ; VBITS_EQ_256-DAG: splice [[WORDS:z[0-9]+]].s, [[PG1]], [[WORDS_LO]].s, [[WORDS_HI]].s
138 ; VBITS_EQ_256-DAG: ptrue [[PG3:p[0-9]+]].s, vl8
139 ; VBITS_EQ_256-NEXT: st1w { [[WORDS]].s }, [[PG3]], [x1]
140 ; VBITS_EQ_256-NEXT: ret
141 %a = load <8 x i64>, <8 x i64>* %ap
142 %val = trunc <8 x i64> %a to <8 x i32>
143 store <8 x i32> %val, <8 x i32>* %dest
147 define void @store_trunc_v16i32i8(<16 x i32>* %ap, <16 x i8>* %dest) #0 {
148 ; CHECK-LABEL: store_trunc_v16i32i8:
149 ; VBITS_GE_512: ptrue p[[P0:[0-9]+]].s, vl16
150 ; VBITS_GE_512-NEXT: ld1w { [[Z0:z[0-9]+]].s }, p0/z, [x0]
151 ; VBITS_GE_512-NEXT: st1b { [[Z0]].s }, p[[P0]], [x1]
152 ; VBITS_GE_512-NEXT: ret
154 ; Ensure sensible type legalisation.
155 ; Currently does not use the truncating store
156 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].s, vl8
157 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #8
158 ; VBITS_EQ_256-DAG: ld1w { [[WORDS_LO:z[0-9]+]].s }, [[PG]]/z, [x0]
159 ; VBITS_EQ_256-DAG: ld1w { [[WORDS_HI:z[0-9]+]].s }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #2]
160 ; VBITS_EQ_256-DAG: uzp1 [[HALFS_LO:z[0-9]+]].h, [[WORDS_LO]].h, [[WORDS_LO]].h
161 ; VBITS_EQ_256-DAG: uzp1 [[HALFS_HI:z[0-9]+]].h, [[WORDS_HI]].h, [[WORDS_HI]].h
162 ; VBITS_EQ_256-DAG: uzp1 z[[BYTES_LO:[0-9]+]].b, [[HALFS_LO]].b, [[HALFS_LO]].b
163 ; VBITS_EQ_256-DAG: uzp1 z[[BYTES_HI:[0-9]+]].b, [[HALFS_HI]].b, [[HALFS_HI]].b
164 ; VBITS_EQ_256-NEXT: mov v[[BYTES_LO]].d[1], v[[BYTES_HI]].d[0]
165 ; VBITS_EQ_256-NEXT: str q[[BYTES_LO]], [x1]
166 ; VBITS_EQ_256-NEXT: ret
167 %a = load <16 x i32>, <16 x i32>* %ap
168 %val = trunc <16 x i32> %a to <16 x i8>
169 store <16 x i8> %val, <16 x i8>* %dest
173 define void @store_trunc_v16i32i16(<16 x i32>* %ap, <16 x i16>* %dest) #0 {
174 ; CHECK-LABEL: store_trunc_v16i32i16:
175 ; VBITS_GE_512: ptrue p[[P0:[0-9]+]].s, vl16
176 ; VBITS_GE_512-NEXT: ld1w { [[Z0:z[0-9]+]].s }, p0/z, [x0]
177 ; VBITS_GE_512-NEXT: st1h { [[Z0]].s }, p[[P0]], [x1]
178 ; VBITS_GE_512-NEXT: ret
180 ; Ensure sensible type legalisation
181 ; VBITS_EQ_256-DAG: ptrue [[PG1:p[0-9]+]].s, vl8
182 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #8
183 ; VBITS_EQ_256-DAG: ld1w { [[WORDS_LO:z[0-9]+]].s }, [[PG1]]/z, [x0]
184 ; VBITS_EQ_256-DAG: ld1w { [[WORDS_HI:z[0-9]+]].s }, [[PG1]]/z, [x0, x[[NUMELTS]], lsl #2]
185 ; VBITS_EQ_256-DAG: ptrue [[PG2:p[0-9]+]].h, vl8
186 ; VBITS_EQ_256-DAG: uzp1 [[HALFS_LO:z[0-9]+]].h, [[WORDS_LO]].h, [[WORDS_LO]].h
187 ; VBITS_EQ_256-DAG: uzp1 [[HALFS_HI:z[0-9]+]].h, [[WORDS_HI]].h, [[WORDS_HI]].h
188 ; VBITS_EQ_256-DAG: splice [[HALFS:z[0-9]+]].h, [[PG2]], [[HALFS_LO]].h, [[HALFS_HI]].h
189 ; VBITS_EQ_256-DAG: ptrue [[PG3:p[0-9]+]].h, vl16
190 ; VBITS_EQ_256-NEXT: st1h { [[HALFS]].h }, [[PG3]], [x1]
191 ; VBITS_EQ_256-NEXT: ret
192 %a = load <16 x i32>, <16 x i32>* %ap
193 %val = trunc <16 x i32> %a to <16 x i16>
194 store <16 x i16> %val, <16 x i16>* %dest
198 define void @store_trunc_v32i16i8(<32 x i16>* %ap, <32 x i8>* %dest) #0 {
199 ; CHECK-LABEL: store_trunc_v32i16i8:
200 ; VBITS_GE_512: ptrue p[[P0:[0-9]+]].h, vl32
201 ; VBITS_GE_512-NEXT: ld1h { [[Z0:z[0-9]+]].h }, p0/z, [x0]
202 ; VBITS_GE_512-NEXT: st1b { [[Z0]].h }, p[[P0]], [x1]
203 ; VBITS_GE_512-NEXT: ret
205 ; Ensure sensible type legalisation
206 ; VBITS_EQ_256-DAG: ptrue [[PG1:p[0-9]+]].h, vl16
207 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #16
208 ; VBITS_EQ_256-DAG: ld1h { [[HALFS_LO:z[0-9]+]].h }, [[PG1]]/z, [x0]
209 ; VBITS_EQ_256-DAG: ld1h { [[HALFS_HI:z[0-9]+]].h }, [[PG1]]/z, [x0, x[[NUMELTS]], lsl #1]
210 ; VBITS_EQ_256-DAG: ptrue [[PG2:p[0-9]+]].b, vl16
211 ; VBITS_EQ_256-DAG: uzp1 [[BYTES_LO:z[0-9]+]].b, [[HALFS_LO]].b, [[HALFS_LO]].b
212 ; VBITS_EQ_256-DAG: uzp1 [[BYTES_HI:z[0-9]+]].b, [[HALFS_HI]].b, [[HALFS_HI]].b
213 ; VBITS_EQ_256-DAG: splice [[BYTES:z[0-9]+]].b, [[PG2]], [[BYTES_LO]].b, [[BYTES_HI]].b
214 ; VBITS_EQ_256-DAG: ptrue [[PG3:p[0-9]+]].b, vl32
215 ; VBITS_EQ_256-NEXT: st1b { [[BYTES]].b }, [[PG3]], [x1]
216 ; VBITS_EQ_256-NEXT: ret
217 %a = load <32 x i16>, <32 x i16>* %ap
218 %val = trunc <32 x i16> %a to <32 x i8>
219 store <32 x i8> %val, <32 x i8>* %dest
223 attributes #0 = { "target-features"="+sve" }