1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mattr=+sve -force-streaming-compatible-sve < %s | FileCheck %s
5 target triple = "aarch64-unknown-linux-gnu"
7 ; REVB pattern for shuffle v32i8 -> v16i16
8 define void @test_revbv16i16(ptr %a) {
9 ; CHECK-LABEL: test_revbv16i16:
11 ; CHECK-NEXT: ptrue p0.h
12 ; CHECK-NEXT: ldp q0, q1, [x0]
13 ; CHECK-NEXT: revb z0.h, p0/m, z0.h
14 ; CHECK-NEXT: revb z1.h, p0/m, z1.h
15 ; CHECK-NEXT: stp q0, q1, [x0]
17 %tmp1 = load <32 x i8>, ptr %a
18 %tmp2 = shufflevector <32 x i8> %tmp1, <32 x i8> undef, <32 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14, i32 17, i32 16, i32 19, i32 18, i32 21, i32 20, i32 23, i32 22, i32 undef, i32 24, i32 27, i32 undef, i32 29, i32 28, i32 undef, i32 undef>
19 store <32 x i8> %tmp2, ptr %a
23 ; REVB pattern for shuffle v32i8 -> v8i32
24 define void @test_revbv8i32(ptr %a) {
25 ; CHECK-LABEL: test_revbv8i32:
27 ; CHECK-NEXT: ptrue p0.s
28 ; CHECK-NEXT: ldp q0, q1, [x0]
29 ; CHECK-NEXT: revb z0.s, p0/m, z0.s
30 ; CHECK-NEXT: revb z1.s, p0/m, z1.s
31 ; CHECK-NEXT: stp q0, q1, [x0]
33 %tmp1 = load <32 x i8>, ptr %a
34 %tmp2 = shufflevector <32 x i8> %tmp1, <32 x i8> undef, <32 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12, i32 19, i32 18, i32 17, i32 16, i32 23, i32 22, i32 21, i32 20, i32 27, i32 undef, i32 undef, i32 undef, i32 31, i32 30, i32 29, i32 undef>
35 store <32 x i8> %tmp2, ptr %a
39 ; REVB pattern for shuffle v32i8 -> v4i64
40 define void @test_revbv4i64(ptr %a) {
41 ; CHECK-LABEL: test_revbv4i64:
43 ; CHECK-NEXT: ptrue p0.d
44 ; CHECK-NEXT: ldp q0, q1, [x0]
45 ; CHECK-NEXT: revb z0.d, p0/m, z0.d
46 ; CHECK-NEXT: revb z1.d, p0/m, z1.d
47 ; CHECK-NEXT: stp q0, q1, [x0]
49 %tmp1 = load <32 x i8>, ptr %a
50 %tmp2 = shufflevector <32 x i8> %tmp1, <32 x i8> undef, <32 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0, i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 23, i32 22, i32 21, i32 20, i32 19, i32 18, i32 17, i32 16, i32 31, i32 30, i32 29, i32 undef, i32 27, i32 undef, i32 undef, i32 undef>
51 store <32 x i8> %tmp2, ptr %a
55 ; REVH pattern for shuffle v16i16 -> v8i32
56 define void @test_revhv8i32(ptr %a) {
57 ; CHECK-LABEL: test_revhv8i32:
59 ; CHECK-NEXT: ptrue p0.s
60 ; CHECK-NEXT: ldp q0, q1, [x0]
61 ; CHECK-NEXT: revh z0.s, p0/m, z0.s
62 ; CHECK-NEXT: revh z1.s, p0/m, z1.s
63 ; CHECK-NEXT: stp q0, q1, [x0]
65 %tmp1 = load <16 x i16>, ptr %a
66 %tmp2 = shufflevector <16 x i16> %tmp1, <16 x i16> undef, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
67 store <16 x i16> %tmp2, ptr %a
71 ; REVH pattern for shuffle v16f16 -> v8f32
72 define void @test_revhv8f32(ptr %a) {
73 ; CHECK-LABEL: test_revhv8f32:
75 ; CHECK-NEXT: ptrue p0.s
76 ; CHECK-NEXT: ldp q0, q1, [x0]
77 ; CHECK-NEXT: revh z0.s, p0/m, z0.s
78 ; CHECK-NEXT: revh z1.s, p0/m, z1.s
79 ; CHECK-NEXT: stp q0, q1, [x0]
81 %tmp1 = load <16 x half>, ptr %a
82 %tmp2 = shufflevector <16 x half> %tmp1, <16 x half> undef, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
83 store <16 x half> %tmp2, ptr %a
87 ; REVH pattern for shuffle v16i16 -> v4i64
88 define void @test_revhv4i64(ptr %a) {
89 ; CHECK-LABEL: test_revhv4i64:
91 ; CHECK-NEXT: ptrue p0.d
92 ; CHECK-NEXT: ldp q0, q1, [x0]
93 ; CHECK-NEXT: revh z0.d, p0/m, z0.d
94 ; CHECK-NEXT: revh z1.d, p0/m, z1.d
95 ; CHECK-NEXT: stp q0, q1, [x0]
97 %tmp1 = load <16 x i16>, ptr %a
98 %tmp2 = shufflevector <16 x i16> %tmp1, <16 x i16> undef, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12>
99 store <16 x i16> %tmp2, ptr %a
103 ; REVW pattern for shuffle v8i32 -> v4i64
104 define void @test_revwv4i64(ptr %a) {
105 ; CHECK-LABEL: test_revwv4i64:
107 ; CHECK-NEXT: ptrue p0.d
108 ; CHECK-NEXT: ldp q0, q1, [x0]
109 ; CHECK-NEXT: revw z0.d, p0/m, z0.d
110 ; CHECK-NEXT: revw z1.d, p0/m, z1.d
111 ; CHECK-NEXT: stp q0, q1, [x0]
113 %tmp1 = load <8 x i32>, ptr %a
114 %tmp2 = shufflevector <8 x i32> %tmp1, <8 x i32> undef, <8 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6>
115 store <8 x i32> %tmp2, ptr %a
119 ; REVW pattern for shuffle v8f32 -> v4f64
120 define void @test_revwv4f64(ptr %a) {
121 ; CHECK-LABEL: test_revwv4f64:
123 ; CHECK-NEXT: ptrue p0.d
124 ; CHECK-NEXT: ldp q0, q1, [x0]
125 ; CHECK-NEXT: revw z0.d, p0/m, z0.d
126 ; CHECK-NEXT: revw z1.d, p0/m, z1.d
127 ; CHECK-NEXT: stp q0, q1, [x0]
129 %tmp1 = load <8 x float>, ptr %a
130 %tmp2 = shufflevector <8 x float> %tmp1, <8 x float> undef, <8 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6>
131 store <8 x float> %tmp2, ptr %a
135 define <16 x i8> @test_revv16i8(ptr %a) {
136 ; CHECK-LABEL: test_revv16i8:
138 ; CHECK-NEXT: ptrue p0.d
139 ; CHECK-NEXT: ldr q0, [x0]
140 ; CHECK-NEXT: revb z0.d, p0/m, z0.d
141 ; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
143 %tmp1 = load <16 x i8>, ptr %a
144 %tmp2 = shufflevector <16 x i8> %tmp1, <16 x i8> undef, <16 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0, i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8>
148 ; REVW pattern for shuffle two v8i32 inputs with the second input available.
149 define void @test_revwv8i32v8i32(ptr %a, ptr %b) {
150 ; CHECK-LABEL: test_revwv8i32v8i32:
152 ; CHECK-NEXT: ptrue p0.d
153 ; CHECK-NEXT: ldp q0, q1, [x1]
154 ; CHECK-NEXT: revw z0.d, p0/m, z0.d
155 ; CHECK-NEXT: revw z1.d, p0/m, z1.d
156 ; CHECK-NEXT: stp q0, q1, [x0]
158 %tmp1 = load <8 x i32>, ptr %a
159 %tmp2 = load <8 x i32>, ptr %b
160 %tmp3 = shufflevector <8 x i32> %tmp1, <8 x i32> %tmp2, <8 x i32> <i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
161 store <8 x i32> %tmp3, ptr %a
165 define void @test_revhv32i16(ptr %a) {
166 ; CHECK-LABEL: test_revhv32i16:
168 ; CHECK-NEXT: ptrue p0.d
169 ; CHECK-NEXT: ldp q0, q1, [x0, #32]
170 ; CHECK-NEXT: ldp q2, q3, [x0]
171 ; CHECK-NEXT: revh z0.d, p0/m, z0.d
172 ; CHECK-NEXT: revh z1.d, p0/m, z1.d
173 ; CHECK-NEXT: revh z2.d, p0/m, z2.d
174 ; CHECK-NEXT: revh z3.d, p0/m, z3.d
175 ; CHECK-NEXT: stp q0, q1, [x0, #32]
176 ; CHECK-NEXT: stp q2, q3, [x0]
178 %tmp1 = load <32 x i16>, ptr %a
179 %tmp2 = shufflevector <32 x i16> %tmp1, <32 x i16> undef, <32 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12, i32 19, i32 18, i32 17, i32 16, i32 23, i32 22, i32 21, i32 20, i32 27, i32 undef, i32 undef, i32 undef, i32 31, i32 30, i32 29, i32 undef>
180 store <32 x i16> %tmp2, ptr %a
184 define void @test_rev_elts_fail(ptr %a) {
185 ; CHECK-LABEL: test_rev_elts_fail:
187 ; CHECK-NEXT: ldp q1, q0, [x0]
188 ; CHECK-NEXT: mov z2.d, z0.d[1]
189 ; CHECK-NEXT: fmov x8, d0
190 ; CHECK-NEXT: mov z0.d, z1.d[1]
191 ; CHECK-NEXT: fmov x9, d2
192 ; CHECK-NEXT: stp x9, x8, [sp, #-32]!
193 ; CHECK-NEXT: .cfi_def_cfa_offset 32
194 ; CHECK-NEXT: fmov x8, d1
195 ; CHECK-NEXT: fmov x9, d0
196 ; CHECK-NEXT: stp x9, x8, [sp, #16]
197 ; CHECK-NEXT: ldp q1, q0, [sp]
198 ; CHECK-NEXT: stp q0, q1, [x0]
199 ; CHECK-NEXT: add sp, sp, #32
201 %tmp1 = load <4 x i64>, ptr %a
202 %tmp2 = shufflevector <4 x i64> %tmp1, <4 x i64> undef, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
203 store <4 x i64> %tmp2, ptr %a
207 ; This is the same test as above, but with sve2p1 it can use the REVD instruction to reverse
208 ; the double-words within quard-words.
209 define void @test_revdv4i64_sve2p1(ptr %a) #1 {
210 ; CHECK-LABEL: test_revdv4i64_sve2p1:
212 ; CHECK-NEXT: ptrue p0.d, vl2
213 ; CHECK-NEXT: ldp q0, q1, [x0]
214 ; CHECK-NEXT: revd z0.q, p0/m, z0.q
215 ; CHECK-NEXT: revd z1.q, p0/m, z1.q
216 ; CHECK-NEXT: stp q0, q1, [x0]
218 %tmp1 = load <4 x i64>, ptr %a
219 %tmp2 = shufflevector <4 x i64> %tmp1, <4 x i64> undef, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
220 store <4 x i64> %tmp2, ptr %a
224 define void @test_revdv4f64_sve2p1(ptr %a) #1 {
225 ; CHECK-LABEL: test_revdv4f64_sve2p1:
227 ; CHECK-NEXT: ptrue p0.d
228 ; CHECK-NEXT: ldp q0, q1, [x0]
229 ; CHECK-NEXT: revd z0.q, p0/m, z0.q
230 ; CHECK-NEXT: revd z1.q, p0/m, z1.q
231 ; CHECK-NEXT: stp q0, q1, [x0]
233 %tmp1 = load <4 x double>, ptr %a
234 %tmp2 = shufflevector <4 x double> %tmp1, <4 x double> undef, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
235 store <4 x double> %tmp2, ptr %a
239 define void @test_revv8i32(ptr %a) {
240 ; CHECK-LABEL: test_revv8i32:
242 ; CHECK-NEXT: sub sp, sp, #32
243 ; CHECK-NEXT: .cfi_def_cfa_offset 32
244 ; CHECK-NEXT: ldp q0, q3, [x0]
245 ; CHECK-NEXT: mov z1.s, z0.s[1]
246 ; CHECK-NEXT: mov z2.s, z0.s[2]
247 ; CHECK-NEXT: mov z4.s, z0.s[3]
248 ; CHECK-NEXT: fmov w8, s0
249 ; CHECK-NEXT: mov z0.s, z3.s[1]
250 ; CHECK-NEXT: fmov w9, s1
251 ; CHECK-NEXT: mov z1.s, z3.s[2]
252 ; CHECK-NEXT: stp w9, w8, [sp, #24]
253 ; CHECK-NEXT: fmov w8, s2
254 ; CHECK-NEXT: fmov w9, s4
255 ; CHECK-NEXT: mov z2.s, z3.s[3]
256 ; CHECK-NEXT: stp w9, w8, [sp, #16]
257 ; CHECK-NEXT: fmov w8, s3
258 ; CHECK-NEXT: fmov w9, s0
259 ; CHECK-NEXT: stp w9, w8, [sp, #8]
260 ; CHECK-NEXT: fmov w8, s1
261 ; CHECK-NEXT: fmov w9, s2
262 ; CHECK-NEXT: stp w9, w8, [sp]
263 ; CHECK-NEXT: ldp q0, q1, [sp]
264 ; CHECK-NEXT: stp q0, q1, [x0]
265 ; CHECK-NEXT: add sp, sp, #32
267 %tmp1 = load <8 x i32>, ptr %a
268 %tmp2 = shufflevector <8 x i32> %tmp1, <8 x i32> undef, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
269 store <8 x i32> %tmp2, ptr %a
272 attributes #1 = { "target-features"="+sve2p1" }