1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -aarch64-enable-mgather-combine=0 < %s | FileCheck %s
3 ; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -aarch64-enable-mgather-combine=1 < %s | FileCheck %s
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ; unscaled unpacked 32-bit offsets
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 define <vscale x 2 x i64> @masked_gather_nxv2i8(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
10 ; CHECK-LABEL: masked_gather_nxv2i8:
12 ; CHECK-NEXT: ld1b { z0.d }, p0/z, [x0, z0.d, sxtw]
14 %ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
15 %vals = call <vscale x 2 x i8> @llvm.masked.gather.nxv2i8(<vscale x 2 x ptr> %ptrs, i32 1, <vscale x 2 x i1> %mask, <vscale x 2 x i8> undef)
16 %vals.zext = zext <vscale x 2 x i8> %vals to <vscale x 2 x i64>
17 ret <vscale x 2 x i64> %vals.zext
20 define <vscale x 2 x i64> @masked_gather_nxv2i16(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
21 ; CHECK-LABEL: masked_gather_nxv2i16:
23 ; CHECK-NEXT: ld1h { z0.d }, p0/z, [x0, z0.d, sxtw]
25 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
26 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
27 %vals = call <vscale x 2 x i16> @llvm.masked.gather.nxv2i16(<vscale x 2 x ptr> %ptrs, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x i16> undef)
28 %vals.zext = zext <vscale x 2 x i16> %vals to <vscale x 2 x i64>
29 ret <vscale x 2 x i64> %vals.zext
32 define <vscale x 2 x i64> @masked_gather_nxv2i32(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
33 ; CHECK-LABEL: masked_gather_nxv2i32:
35 ; CHECK-NEXT: ld1w { z0.d }, p0/z, [x0, z0.d, sxtw]
37 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
38 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
39 %vals = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32(<vscale x 2 x ptr> %ptrs, i32 4, <vscale x 2 x i1> %mask, <vscale x 2 x i32> undef)
40 %vals.zext = zext <vscale x 2 x i32> %vals to <vscale x 2 x i64>
41 ret <vscale x 2 x i64> %vals.zext
44 define <vscale x 2 x i64> @masked_gather_nxv2i64(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
45 ; CHECK-LABEL: masked_gather_nxv2i64:
47 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0, z0.d, sxtw]
49 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
50 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
51 %vals = call <vscale x 2 x i64> @llvm.masked.gather.nxv2i64(<vscale x 2 x ptr> %ptrs, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x i64> undef)
52 ret <vscale x 2 x i64> %vals
55 define <vscale x 2 x half> @masked_gather_nxv2f16(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
56 ; CHECK-LABEL: masked_gather_nxv2f16:
58 ; CHECK-NEXT: ld1h { z0.d }, p0/z, [x0, z0.d, sxtw]
60 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
61 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
62 %vals = call <vscale x 2 x half> @llvm.masked.gather.nxv2f16(<vscale x 2 x ptr> %ptrs, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x half> undef)
63 ret <vscale x 2 x half> %vals
66 define <vscale x 2 x bfloat> @masked_gather_nxv2bf16(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) #0 {
67 ; CHECK-LABEL: masked_gather_nxv2bf16:
69 ; CHECK-NEXT: ld1h { z0.d }, p0/z, [x0, z0.d, sxtw]
71 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
72 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
73 %vals = call <vscale x 2 x bfloat> @llvm.masked.gather.nxv2bf16(<vscale x 2 x ptr> %ptrs, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x bfloat> undef)
74 ret <vscale x 2 x bfloat> %vals
77 define <vscale x 2 x float> @masked_gather_nxv2f32(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
78 ; CHECK-LABEL: masked_gather_nxv2f32:
80 ; CHECK-NEXT: ld1w { z0.d }, p0/z, [x0, z0.d, sxtw]
82 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
83 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
84 %vals = call <vscale x 2 x float> @llvm.masked.gather.nxv2f32(<vscale x 2 x ptr> %ptrs, i32 4, <vscale x 2 x i1> %mask, <vscale x 2 x float> undef)
85 ret <vscale x 2 x float> %vals
88 define <vscale x 2 x double> @masked_gather_nxv2f64(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
89 ; CHECK-LABEL: masked_gather_nxv2f64:
91 ; CHECK-NEXT: ld1d { z0.d }, p0/z, [x0, z0.d, sxtw]
93 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
94 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
95 %vals = call <vscale x 2 x double> @llvm.masked.gather.nxv2f64(<vscale x 2 x ptr> %ptrs, i32 8, <vscale x 2 x i1> %mask, <vscale x 2 x double> undef)
96 ret <vscale x 2 x double> %vals
99 define <vscale x 2 x i64> @masked_sgather_nxv2i8(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
100 ; CHECK-LABEL: masked_sgather_nxv2i8:
102 ; CHECK-NEXT: ld1sb { z0.d }, p0/z, [x0, z0.d, sxtw]
104 %ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
105 %vals = call <vscale x 2 x i8> @llvm.masked.gather.nxv2i8(<vscale x 2 x ptr> %ptrs, i32 1, <vscale x 2 x i1> %mask, <vscale x 2 x i8> undef)
106 %vals.sext = sext <vscale x 2 x i8> %vals to <vscale x 2 x i64>
107 ret <vscale x 2 x i64> %vals.sext
110 define <vscale x 2 x i64> @masked_sgather_nxv2i16(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
111 ; CHECK-LABEL: masked_sgather_nxv2i16:
113 ; CHECK-NEXT: ld1sh { z0.d }, p0/z, [x0, z0.d, sxtw]
115 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
116 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
117 %vals = call <vscale x 2 x i16> @llvm.masked.gather.nxv2i16(<vscale x 2 x ptr> %ptrs, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x i16> undef)
118 %vals.sext = sext <vscale x 2 x i16> %vals to <vscale x 2 x i64>
119 ret <vscale x 2 x i64> %vals.sext
122 define <vscale x 2 x i64> @masked_sgather_nxv2i32(ptr %base, <vscale x 2 x i32> %offsets, <vscale x 2 x i1> %mask) {
123 ; CHECK-LABEL: masked_sgather_nxv2i32:
125 ; CHECK-NEXT: ld1sw { z0.d }, p0/z, [x0, z0.d, sxtw]
127 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 2 x i32> %offsets
128 %ptrs = bitcast <vscale x 2 x ptr> %byte_ptrs to <vscale x 2 x ptr>
129 %vals = call <vscale x 2 x i32> @llvm.masked.gather.nxv2i32(<vscale x 2 x ptr> %ptrs, i32 4, <vscale x 2 x i1> %mask, <vscale x 2 x i32> undef)
130 %vals.sext = sext <vscale x 2 x i32> %vals to <vscale x 2 x i64>
131 ret <vscale x 2 x i64> %vals.sext
134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
135 ; unscaled packed 32-bit offsets
136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
138 define <vscale x 4 x i32> @masked_gather_nxv4i8(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) {
139 ; CHECK-LABEL: masked_gather_nxv4i8:
141 ; CHECK-NEXT: ld1b { z0.s }, p0/z, [x0, z0.s, sxtw]
143 %ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
144 %vals = call <vscale x 4 x i8> @llvm.masked.gather.nxv4i8(<vscale x 4 x ptr> %ptrs, i32 1, <vscale x 4 x i1> %mask, <vscale x 4 x i8> undef)
145 %vals.zext = zext <vscale x 4 x i8> %vals to <vscale x 4 x i32>
146 ret <vscale x 4 x i32> %vals.zext
149 define <vscale x 4 x i32> @masked_gather_nxv4i16(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) {
150 ; CHECK-LABEL: masked_gather_nxv4i16:
152 ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x0, z0.s, sxtw]
154 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
155 %ptrs = bitcast <vscale x 4 x ptr> %byte_ptrs to <vscale x 4 x ptr>
156 %vals = call <vscale x 4 x i16> @llvm.masked.gather.nxv4i16(<vscale x 4 x ptr> %ptrs, i32 2, <vscale x 4 x i1> %mask, <vscale x 4 x i16> undef)
157 %vals.zext = zext <vscale x 4 x i16> %vals to <vscale x 4 x i32>
158 ret <vscale x 4 x i32> %vals.zext
161 define <vscale x 4 x i32> @masked_gather_nxv4i32(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) {
162 ; CHECK-LABEL: masked_gather_nxv4i32:
164 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0, z0.s, sxtw]
166 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
167 %ptrs = bitcast <vscale x 4 x ptr> %byte_ptrs to <vscale x 4 x ptr>
168 %vals = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32(<vscale x 4 x ptr> %ptrs, i32 4, <vscale x 4 x i1> %mask, <vscale x 4 x i32> undef)
169 ret <vscale x 4 x i32> %vals
172 define <vscale x 4 x half> @masked_gather_nxv4f16(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) {
173 ; CHECK-LABEL: masked_gather_nxv4f16:
175 ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x0, z0.s, sxtw]
177 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
178 %ptrs = bitcast <vscale x 4 x ptr> %byte_ptrs to <vscale x 4 x ptr>
179 %vals = call <vscale x 4 x half> @llvm.masked.gather.nxv4f16(<vscale x 4 x ptr> %ptrs, i32 2, <vscale x 4 x i1> %mask, <vscale x 4 x half> undef)
180 ret <vscale x 4 x half> %vals
183 define <vscale x 4 x bfloat> @masked_gather_nxv4bf16(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) #0 {
184 ; CHECK-LABEL: masked_gather_nxv4bf16:
186 ; CHECK-NEXT: ld1h { z0.s }, p0/z, [x0, z0.s, sxtw]
188 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
189 %ptrs = bitcast <vscale x 4 x ptr> %byte_ptrs to <vscale x 4 x ptr>
190 %vals = call <vscale x 4 x bfloat> @llvm.masked.gather.nxv4bf16(<vscale x 4 x ptr> %ptrs, i32 2, <vscale x 4 x i1> %mask, <vscale x 4 x bfloat> undef)
191 ret <vscale x 4 x bfloat> %vals
194 define <vscale x 4 x float> @masked_gather_nxv4f32(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) {
195 ; CHECK-LABEL: masked_gather_nxv4f32:
197 ; CHECK-NEXT: ld1w { z0.s }, p0/z, [x0, z0.s, sxtw]
199 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
200 %ptrs = bitcast <vscale x 4 x ptr> %byte_ptrs to <vscale x 4 x ptr>
201 %vals = call <vscale x 4 x float> @llvm.masked.gather.nxv4f32(<vscale x 4 x ptr> %ptrs, i32 4, <vscale x 4 x i1> %mask, <vscale x 4 x float> undef)
202 ret <vscale x 4 x float> %vals
205 define <vscale x 4 x i32> @masked_sgather_nxv4i8(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) {
206 ; CHECK-LABEL: masked_sgather_nxv4i8:
208 ; CHECK-NEXT: ld1sb { z0.s }, p0/z, [x0, z0.s, sxtw]
210 %ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
211 %vals = call <vscale x 4 x i8> @llvm.masked.gather.nxv4i8(<vscale x 4 x ptr> %ptrs, i32 1, <vscale x 4 x i1> %mask, <vscale x 4 x i8> undef)
212 %vals.sext = sext <vscale x 4 x i8> %vals to <vscale x 4 x i32>
213 ret <vscale x 4 x i32> %vals.sext
216 define <vscale x 4 x i32> @masked_sgather_nxv4i16(ptr %base, <vscale x 4 x i32> %offsets, <vscale x 4 x i1> %mask) {
217 ; CHECK-LABEL: masked_sgather_nxv4i16:
219 ; CHECK-NEXT: ld1sh { z0.s }, p0/z, [x0, z0.s, sxtw]
221 %byte_ptrs = getelementptr i8, ptr %base, <vscale x 4 x i32> %offsets
222 %ptrs = bitcast <vscale x 4 x ptr> %byte_ptrs to <vscale x 4 x ptr>
223 %vals = call <vscale x 4 x i16> @llvm.masked.gather.nxv4i16(<vscale x 4 x ptr> %ptrs, i32 2, <vscale x 4 x i1> %mask, <vscale x 4 x i16> undef)
224 %vals.sext = sext <vscale x 4 x i16> %vals to <vscale x 4 x i32>
225 ret <vscale x 4 x i32> %vals.sext
228 declare <vscale x 2 x i8> @llvm.masked.gather.nxv2i8(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x i8>)
229 declare <vscale x 2 x i16> @llvm.masked.gather.nxv2i16(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x i16>)
230 declare <vscale x 2 x i32> @llvm.masked.gather.nxv2i32(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x i32>)
231 declare <vscale x 2 x i64> @llvm.masked.gather.nxv2i64(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x i64>)
232 declare <vscale x 2 x half> @llvm.masked.gather.nxv2f16(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x half>)
233 declare <vscale x 2 x bfloat> @llvm.masked.gather.nxv2bf16(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x bfloat>)
234 declare <vscale x 2 x float> @llvm.masked.gather.nxv2f32(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x float>)
235 declare <vscale x 2 x double> @llvm.masked.gather.nxv2f64(<vscale x 2 x ptr>, i32, <vscale x 2 x i1>, <vscale x 2 x double>)
237 declare <vscale x 4 x i8> @llvm.masked.gather.nxv4i8(<vscale x 4 x ptr>, i32, <vscale x 4 x i1>, <vscale x 4 x i8>)
238 declare <vscale x 4 x i16> @llvm.masked.gather.nxv4i16(<vscale x 4 x ptr>, i32, <vscale x 4 x i1>, <vscale x 4 x i16>)
239 declare <vscale x 4 x i32> @llvm.masked.gather.nxv4i32(<vscale x 4 x ptr>, i32, <vscale x 4 x i1>, <vscale x 4 x i32>)
240 declare <vscale x 4 x half> @llvm.masked.gather.nxv4f16(<vscale x 4 x ptr>, i32, <vscale x 4 x i1>, <vscale x 4 x half>)
241 declare <vscale x 4 x bfloat> @llvm.masked.gather.nxv4bf16(<vscale x 4 x ptr>, i32, <vscale x 4 x i1>, <vscale x 4 x bfloat>)
242 declare <vscale x 4 x float> @llvm.masked.gather.nxv4f32(<vscale x 4 x ptr>, i32, <vscale x 4 x i1>, <vscale x 4 x float>)
243 attributes #0 = { "target-features"="+sve,+bf16" }