Skip to content

Commit 458a315

Browse files
committed
[RISCV] Add more tests for strided gathers with scalar offsets. NFC
1 parent 68a6481 commit 458a315

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,66 @@ define <vscale x 1 x i64> @vector_base_scalar_offset(ptr %p, i64 %offset) {
319319
ret <vscale x 1 x i64> %x
320320
}
321321

322+
define <vscale x 1 x i64> @splat_base_scalar_offset(ptr %p, i64 %offset) {
323+
; CHECK-LABEL: @splat_base_scalar_offset(
324+
; CHECK-NEXT: [[HEAD:%.*]] = insertelement <vscale x 1 x ptr> poison, ptr [[P:%.*]], i32 0
325+
; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <vscale x 1 x ptr> [[HEAD]], <vscale x 1 x ptr> poison, <vscale x 1 x i32> zeroinitializer
326+
; CHECK-NEXT: [[PTRS:%.*]] = getelementptr i64, <vscale x 1 x ptr> [[SPLAT]], i64 [[OFFSET:%.*]]
327+
; CHECK-NEXT: [[X:%.*]] = call <vscale x 1 x i64> @llvm.masked.gather.nxv1i64.nxv1p0(<vscale x 1 x ptr> [[PTRS]], i32 8, <vscale x 1 x i1> shufflevector (<vscale x 1 x i1> insertelement (<vscale x 1 x i1> poison, i1 true, i64 0), <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i64> poison)
328+
; CHECK-NEXT: ret <vscale x 1 x i64> [[X]]
329+
;
330+
%head = insertelement <vscale x 1 x ptr> poison, ptr %p, i32 0
331+
%splat = shufflevector <vscale x 1 x ptr> %head, <vscale x 1 x ptr> poison, <vscale x 1 x i32> zeroinitializer
332+
%ptrs = getelementptr i64, <vscale x 1 x ptr> %splat, i64 %offset
333+
%x = call <vscale x 1 x i64> @llvm.masked.gather.nxv1i64.nxv1p0(
334+
<vscale x 1 x ptr> %ptrs,
335+
i32 8,
336+
<vscale x 1 x i1> splat (i1 1),
337+
<vscale x 1 x i64> poison
338+
)
339+
ret <vscale x 1 x i64> %x
340+
}
341+
342+
; We shouldn't be able to determine a stride here.
343+
define <vscale x 1 x i64> @nonstrided_base_scalar_offset(ptr %p, <vscale x 1 x i64> %v, i64 %offset) {
344+
; CHECK-LABEL: @nonstrided_base_scalar_offset(
345+
; CHECK-NEXT: [[PTRS1:%.*]] = getelementptr i64, ptr [[P:%.*]], <vscale x 1 x i64> [[V:%.*]]
346+
; CHECK-NEXT: [[PTRS2:%.*]] = getelementptr i64, <vscale x 1 x ptr> [[PTRS1]], i64 [[OFFSET:%.*]]
347+
; CHECK-NEXT: [[X:%.*]] = call <vscale x 1 x i64> @llvm.masked.gather.nxv1i64.nxv1p0(<vscale x 1 x ptr> [[PTRS2]], i32 8, <vscale x 1 x i1> shufflevector (<vscale x 1 x i1> insertelement (<vscale x 1 x i1> poison, i1 true, i64 0), <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i64> poison)
348+
; CHECK-NEXT: ret <vscale x 1 x i64> [[X]]
349+
;
350+
%ptrs1 = getelementptr i64, ptr %p, <vscale x 1 x i64> %v
351+
%ptrs2 = getelementptr i64, <vscale x 1 x ptr> %ptrs1, i64 %offset
352+
%x = call <vscale x 1 x i64> @llvm.masked.gather.nxv1i64.nxv1p0(
353+
<vscale x 1 x ptr> %ptrs2,
354+
i32 8,
355+
<vscale x 1 x i1> splat (i1 1),
356+
<vscale x 1 x i64> poison
357+
)
358+
ret <vscale x 1 x i64> %x
359+
}
360+
361+
; We shouldn't be able to determine a scalar base here.
362+
define <vscale x 1 x i64> @vector_base_vector_offset(ptr %p, <vscale x 1 x i64> %offset) {
363+
; CHECK-LABEL: @vector_base_vector_offset(
364+
; CHECK-NEXT: [[STEP:%.*]] = call <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
365+
; CHECK-NEXT: [[PTRS1:%.*]] = getelementptr i64, ptr [[P:%.*]], <vscale x 1 x i64> [[STEP]]
366+
; CHECK-NEXT: [[PTRS2:%.*]] = getelementptr i64, <vscale x 1 x ptr> [[PTRS1]], <vscale x 1 x i64> [[OFFSET:%.*]]
367+
; CHECK-NEXT: [[X:%.*]] = call <vscale x 1 x i64> @llvm.masked.gather.nxv1i64.nxv1p0(<vscale x 1 x ptr> [[PTRS2]], i32 8, <vscale x 1 x i1> shufflevector (<vscale x 1 x i1> insertelement (<vscale x 1 x i1> poison, i1 true, i64 0), <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer), <vscale x 1 x i64> poison)
368+
; CHECK-NEXT: ret <vscale x 1 x i64> [[X]]
369+
;
370+
%step = call <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
371+
%ptrs1 = getelementptr i64, ptr %p, <vscale x 1 x i64> %step
372+
%ptrs2 = getelementptr i64, <vscale x 1 x ptr> %ptrs1, <vscale x 1 x i64> %offset
373+
%x = call <vscale x 1 x i64> @llvm.masked.gather.nxv1i64.nxv1p0(
374+
<vscale x 1 x ptr> %ptrs2,
375+
i32 8,
376+
<vscale x 1 x i1> splat (i1 1),
377+
<vscale x 1 x i64> poison
378+
)
379+
ret <vscale x 1 x i64> %x
380+
}
381+
322382
declare i64 @llvm.vscale.i64()
323383
declare void @llvm.masked.scatter.nxv1i64.nxv1p0(<vscale x 1 x i64>, <vscale x 1 x ptr>, i32, <vscale x 1 x i1>)
324384
declare <vscale x 1 x i64> @llvm.masked.gather.nxv1i64.nxv1p0(<vscale x 1 x ptr>, i32, <vscale x 1 x i1>, <vscale x 1 x i64>)

0 commit comments

Comments
 (0)