1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=aarch64 -mattr=+sve < %s -o - | FileCheck --check-prefixes=CHECK,SVE %s
3 ; RUN: llc -mtriple=aarch64 -mattr=+sve2 < %s -o - | FileCheck --check-prefixes=CHECK,SVE2 %s
5 ; Wrong add/shift amount. Should be 32 for shift of 6.
6 define <vscale x 2 x i64> @neg_urshr_1(<vscale x 2 x i64> %x) {
7 ; CHECK-LABEL: neg_urshr_1:
9 ; CHECK-NEXT: add z0.d, z0.d, #16 // =0x10
10 ; CHECK-NEXT: lsr z0.d, z0.d, #6
12 %add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 16)
13 %sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
14 ret <vscale x 2 x i64> %sh
18 define <vscale x 2 x i64> @neg_urshr_2(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y) {
19 ; CHECK-LABEL: neg_urshr_2:
21 ; CHECK-NEXT: add z0.d, z0.d, #32 // =0x20
22 ; CHECK-NEXT: ptrue p0.d
23 ; CHECK-NEXT: lsr z0.d, p0/m, z0.d, z1.d
25 %add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 32)
26 %sh = lshr <vscale x 2 x i64> %add, %y
27 ret <vscale x 2 x i64> %sh
31 define <vscale x 2 x i64> @neg_urshr_3(<vscale x 2 x i64> %x, <vscale x 2 x i64> %y) {
32 ; CHECK-LABEL: neg_urshr_3:
34 ; CHECK-NEXT: add z0.d, z0.d, z1.d
35 ; CHECK-NEXT: lsr z0.d, z0.d, #6
37 %add = add nuw nsw <vscale x 2 x i64> %x, %y
38 %sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
39 ret <vscale x 2 x i64> %sh
43 define <vscale x 2 x i64> @neg_urshr_4(<vscale x 2 x i64> %x, ptr %p) {
44 ; CHECK-LABEL: neg_urshr_4:
46 ; CHECK-NEXT: mov z1.d, z0.d
47 ; CHECK-NEXT: ptrue p0.d
48 ; CHECK-NEXT: add z1.d, z1.d, #32 // =0x20
49 ; CHECK-NEXT: lsr z0.d, z1.d, #6
50 ; CHECK-NEXT: st1d { z1.d }, p0, [x0]
52 %add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 32)
53 %sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
54 store <vscale x 2 x i64> %add, ptr %p
55 ret <vscale x 2 x i64> %sh
59 define <vscale x 2 x i64> @neg_urshr_5(<vscale x 2 x i64> %x) {
60 ; CHECK-LABEL: neg_urshr_5:
62 ; CHECK-NEXT: add z0.d, z0.d, #32 // =0x20
63 ; CHECK-NEXT: lsr z0.d, z0.d, #6
65 %add = add <vscale x 2 x i64> %x, splat (i64 32)
66 %sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
67 ret <vscale x 2 x i64> %sh
70 define <vscale x 16 x i8> @urshr_i8(<vscale x 16 x i8> %x) {
71 ; SVE-LABEL: urshr_i8:
73 ; SVE-NEXT: add z0.b, z0.b, #32 // =0x20
74 ; SVE-NEXT: lsr z0.b, z0.b, #6
77 ; SVE2-LABEL: urshr_i8:
79 ; SVE2-NEXT: ptrue p0.b
80 ; SVE2-NEXT: urshr z0.b, p0/m, z0.b, #6
82 %add = add nuw nsw <vscale x 16 x i8> %x, splat (i8 32)
83 %sh = lshr <vscale x 16 x i8> %add, splat (i8 6)
84 ret <vscale x 16 x i8> %sh
87 define <vscale x 16 x i8> @urshr_8_wide_trunc(<vscale x 16 x i8> %x) {
88 ; SVE-LABEL: urshr_8_wide_trunc:
90 ; SVE-NEXT: uunpkhi z1.h, z0.b
91 ; SVE-NEXT: uunpklo z0.h, z0.b
92 ; SVE-NEXT: add z0.h, z0.h, #32 // =0x20
93 ; SVE-NEXT: add z1.h, z1.h, #32 // =0x20
94 ; SVE-NEXT: lsr z1.h, z1.h, #6
95 ; SVE-NEXT: lsr z0.h, z0.h, #6
96 ; SVE-NEXT: uzp1 z0.b, z0.b, z1.b
99 ; SVE2-LABEL: urshr_8_wide_trunc:
101 ; SVE2-NEXT: ptrue p0.b
102 ; SVE2-NEXT: urshr z0.b, p0/m, z0.b, #6
104 %ext = zext <vscale x 16 x i8> %x to <vscale x 16 x i16>
105 %add = add nuw nsw <vscale x 16 x i16> %ext, splat (i16 32)
106 %sh = lshr <vscale x 16 x i16> %add, splat (i16 6)
107 %sht = trunc <vscale x 16 x i16> %sh to <vscale x 16 x i8>
108 ret <vscale x 16 x i8> %sht
111 define <vscale x 16 x i8> @urshr_8_wide_trunc_nomerge(<vscale x 16 x i16> %ext) {
112 ; SVE-LABEL: urshr_8_wide_trunc_nomerge:
114 ; SVE-NEXT: add z0.h, z0.h, #256 // =0x100
115 ; SVE-NEXT: add z1.h, z1.h, #256 // =0x100
116 ; SVE-NEXT: lsr z1.h, z1.h, #9
117 ; SVE-NEXT: lsr z0.h, z0.h, #9
118 ; SVE-NEXT: uzp1 z0.b, z0.b, z1.b
121 ; SVE2-LABEL: urshr_8_wide_trunc_nomerge:
123 ; SVE2-NEXT: ptrue p0.h
124 ; SVE2-NEXT: urshr z1.h, p0/m, z1.h, #9
125 ; SVE2-NEXT: urshr z0.h, p0/m, z0.h, #9
126 ; SVE2-NEXT: uzp1 z0.b, z0.b, z1.b
128 %add = add nuw nsw <vscale x 16 x i16> %ext, splat (i16 256)
129 %sh = lshr <vscale x 16 x i16> %add, splat (i16 9)
130 %sht = trunc <vscale x 16 x i16> %sh to <vscale x 16 x i8>
131 ret <vscale x 16 x i8> %sht
134 define <vscale x 8 x i16> @urshr_i16(<vscale x 8 x i16> %x) {
135 ; SVE-LABEL: urshr_i16:
137 ; SVE-NEXT: add z0.h, z0.h, #32 // =0x20
138 ; SVE-NEXT: lsr z0.h, z0.h, #6
141 ; SVE2-LABEL: urshr_i16:
143 ; SVE2-NEXT: ptrue p0.h
144 ; SVE2-NEXT: urshr z0.h, p0/m, z0.h, #6
146 %add = add nuw nsw <vscale x 8 x i16> %x, splat (i16 32)
147 %sh = lshr <vscale x 8 x i16> %add, splat (i16 6)
148 ret <vscale x 8 x i16> %sh
151 define <vscale x 8 x i16> @urshr_16_wide_trunc(<vscale x 8 x i16> %x) {
152 ; SVE-LABEL: urshr_16_wide_trunc:
154 ; SVE-NEXT: uunpkhi z1.s, z0.h
155 ; SVE-NEXT: uunpklo z0.s, z0.h
156 ; SVE-NEXT: add z0.s, z0.s, #32 // =0x20
157 ; SVE-NEXT: add z1.s, z1.s, #32 // =0x20
158 ; SVE-NEXT: lsr z1.s, z1.s, #6
159 ; SVE-NEXT: lsr z0.s, z0.s, #6
160 ; SVE-NEXT: uzp1 z0.h, z0.h, z1.h
163 ; SVE2-LABEL: urshr_16_wide_trunc:
165 ; SVE2-NEXT: ptrue p0.h
166 ; SVE2-NEXT: urshr z0.h, p0/m, z0.h, #6
168 %ext = zext <vscale x 8 x i16> %x to <vscale x 8 x i32>
169 %add = add nuw nsw <vscale x 8 x i32> %ext, splat (i32 32)
170 %sh = lshr <vscale x 8 x i32> %add, splat (i32 6)
171 %sht = trunc <vscale x 8 x i32> %sh to <vscale x 8 x i16>
172 ret <vscale x 8 x i16> %sht
175 define <vscale x 8 x i16> @urshr_16_wide_trunc_nomerge(<vscale x 8 x i32> %ext) {
176 ; SVE-LABEL: urshr_16_wide_trunc_nomerge:
178 ; SVE-NEXT: mov z2.s, #0x10000
179 ; SVE-NEXT: add z0.s, z0.s, z2.s
180 ; SVE-NEXT: add z1.s, z1.s, z2.s
181 ; SVE-NEXT: lsr z1.s, z1.s, #17
182 ; SVE-NEXT: lsr z0.s, z0.s, #17
183 ; SVE-NEXT: uzp1 z0.h, z0.h, z1.h
186 ; SVE2-LABEL: urshr_16_wide_trunc_nomerge:
188 ; SVE2-NEXT: ptrue p0.s
189 ; SVE2-NEXT: urshr z1.s, p0/m, z1.s, #17
190 ; SVE2-NEXT: urshr z0.s, p0/m, z0.s, #17
191 ; SVE2-NEXT: uzp1 z0.h, z0.h, z1.h
193 %add = add nuw nsw <vscale x 8 x i32> %ext, splat (i32 65536)
194 %sh = lshr <vscale x 8 x i32> %add, splat (i32 17)
195 %sht = trunc <vscale x 8 x i32> %sh to <vscale x 8 x i16>
196 ret <vscale x 8 x i16> %sht
199 define <vscale x 4 x i32> @urshr_i32(<vscale x 4 x i32> %x) {
200 ; SVE-LABEL: urshr_i32:
202 ; SVE-NEXT: add z0.s, z0.s, #32 // =0x20
203 ; SVE-NEXT: lsr z0.s, z0.s, #6
206 ; SVE2-LABEL: urshr_i32:
208 ; SVE2-NEXT: ptrue p0.s
209 ; SVE2-NEXT: urshr z0.s, p0/m, z0.s, #6
211 %add = add nuw nsw <vscale x 4 x i32> %x, splat (i32 32)
212 %sh = lshr <vscale x 4 x i32> %add, splat (i32 6)
213 ret <vscale x 4 x i32> %sh
216 define <vscale x 4 x i32> @urshr_32_wide_trunc(<vscale x 4 x i32> %x) {
217 ; SVE-LABEL: urshr_32_wide_trunc:
219 ; SVE-NEXT: uunpkhi z1.d, z0.s
220 ; SVE-NEXT: uunpklo z0.d, z0.s
221 ; SVE-NEXT: add z0.d, z0.d, #32 // =0x20
222 ; SVE-NEXT: add z1.d, z1.d, #32 // =0x20
223 ; SVE-NEXT: lsr z1.d, z1.d, #6
224 ; SVE-NEXT: lsr z0.d, z0.d, #6
225 ; SVE-NEXT: uzp1 z0.s, z0.s, z1.s
228 ; SVE2-LABEL: urshr_32_wide_trunc:
230 ; SVE2-NEXT: ptrue p0.s
231 ; SVE2-NEXT: urshr z0.s, p0/m, z0.s, #6
233 %ext = zext <vscale x 4 x i32> %x to <vscale x 4 x i64>
234 %add = add nuw nsw <vscale x 4 x i64> %ext, splat (i64 32)
235 %sh = lshr <vscale x 4 x i64> %add, splat (i64 6)
236 %sht = trunc <vscale x 4 x i64> %sh to <vscale x 4 x i32>
237 ret <vscale x 4 x i32> %sht
240 define <vscale x 4 x i32> @urshr_32_wide_trunc_nomerge(<vscale x 4 x i64> %ext) {
241 ; SVE-LABEL: urshr_32_wide_trunc_nomerge:
243 ; SVE-NEXT: mov z2.d, #0x100000000
244 ; SVE-NEXT: add z0.d, z0.d, z2.d
245 ; SVE-NEXT: add z1.d, z1.d, z2.d
246 ; SVE-NEXT: lsr z1.d, z1.d, #33
247 ; SVE-NEXT: lsr z0.d, z0.d, #33
248 ; SVE-NEXT: uzp1 z0.s, z0.s, z1.s
251 ; SVE2-LABEL: urshr_32_wide_trunc_nomerge:
253 ; SVE2-NEXT: ptrue p0.d
254 ; SVE2-NEXT: urshr z1.d, p0/m, z1.d, #33
255 ; SVE2-NEXT: urshr z0.d, p0/m, z0.d, #33
256 ; SVE2-NEXT: uzp1 z0.s, z0.s, z1.s
258 %add = add nuw nsw <vscale x 4 x i64> %ext, splat (i64 4294967296)
259 %sh = lshr <vscale x 4 x i64> %add, splat (i64 33)
260 %sht = trunc <vscale x 4 x i64> %sh to <vscale x 4 x i32>
261 ret <vscale x 4 x i32> %sht
264 define <vscale x 2 x i64> @urshr_i64(<vscale x 2 x i64> %x) {
265 ; SVE-LABEL: urshr_i64:
267 ; SVE-NEXT: add z0.d, z0.d, #32 // =0x20
268 ; SVE-NEXT: lsr z0.d, z0.d, #6
271 ; SVE2-LABEL: urshr_i64:
273 ; SVE2-NEXT: ptrue p0.d
274 ; SVE2-NEXT: urshr z0.d, p0/m, z0.d, #6
276 %add = add nuw nsw <vscale x 2 x i64> %x, splat (i64 32)
277 %sh = lshr <vscale x 2 x i64> %add, splat (i64 6)
278 ret <vscale x 2 x i64> %sh