[llvm] 2da8ed3 - [RISCV] Add tests for gather scatter pass for non-recursive mul strides
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 27 12:22:19 PDT 2023
Author: Luke Lau
Date: 2023-03-27T20:21:44+01:00
New Revision: 2da8ed3d78bb4c4ba5548ae5b386f545ab2cc8b5
URL: https://github.com/llvm/llvm-project/commit/2da8ed3d78bb4c4ba5548ae5b386f545ab2cc8b5
DIFF: https://github.com/llvm/llvm-project/commit/2da8ed3d78bb4c4ba5548ae5b386f545ab2cc8b5.diff
LOG: [RISCV] Add tests for gather scatter pass for non-recursive mul strides
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D146982
Added:
Modified:
llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll b/llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll
index be151e4377c45..31fcf10fa3804 100644
--- a/llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll
@@ -89,6 +89,54 @@ for.cond.cleanup: ; preds = %vector.body
ret void
}
+define <vscale x 1 x i64> @gather_loopless(ptr %p, i64 %stride) {
+; CHECK-LABEL: @gather_loopless(
+; CHECK-NEXT: [[STEP:%.*]] = call <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
+; CHECK-NEXT: [[SPLAT_INSERT:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[STRIDE:%.*]], i64 0
+; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[SPLAT_INSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; CHECK-NEXT: [[OFFSETS:%.*]] = mul <vscale x 1 x i64> [[STEP]], [[SPLAT]]
+; CHECK-NEXT: [[PTRS:%.*]] = getelementptr i32, ptr [[P:%.*]], <vscale x 1 x i64> [[OFFSETS]]
+; 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)
+; CHECK-NEXT: ret <vscale x 1 x i64> [[X]]
+;
+ %step = call <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
+ %splat.insert = insertelement <vscale x 1 x i64> poison, i64 %stride, i64 0
+ %splat = shufflevector <vscale x 1 x i64> %splat.insert, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %offsets = mul <vscale x 1 x i64> %step, %splat
+ %ptrs = getelementptr i32, ptr %p, <vscale x 1 x i64> %offsets
+ %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 1, i64 0), <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer),
+ <vscale x 1 x i64> poison
+ )
+ ret <vscale x 1 x i64> %x
+}
+
+define void @scatter_loopless(<vscale x 1 x i64> %x, ptr %p, i64 %stride) {
+; CHECK-LABEL: @scatter_loopless(
+; CHECK-NEXT: [[STEP:%.*]] = call <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
+; CHECK-NEXT: [[SPLAT_INSERT:%.*]] = insertelement <vscale x 1 x i64> poison, i64 [[STRIDE:%.*]], i64 0
+; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <vscale x 1 x i64> [[SPLAT_INSERT]], <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+; CHECK-NEXT: [[OFFSETS:%.*]] = mul <vscale x 1 x i64> [[STEP]], [[SPLAT]]
+; CHECK-NEXT: [[PTRS:%.*]] = getelementptr i32, ptr [[P:%.*]], <vscale x 1 x i64> [[OFFSETS]]
+; CHECK-NEXT: call void @llvm.masked.scatter.nxv1i64.nxv1p0(<vscale x 1 x i64> [[X:%.*]], <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))
+; CHECK-NEXT: ret void
+;
+ %step = call <vscale x 1 x i64> @llvm.experimental.stepvector.nxv1i64()
+ %splat.insert = insertelement <vscale x 1 x i64> poison, i64 %stride, i64 0
+ %splat = shufflevector <vscale x 1 x i64> %splat.insert, <vscale x 1 x i64> poison, <vscale x 1 x i32> zeroinitializer
+ %offsets = mul <vscale x 1 x i64> %step, %splat
+ %ptrs = getelementptr i32, ptr %p, <vscale x 1 x i64> %offsets
+ call void @llvm.masked.scatter.nxv1i64.nxv1p0(
+ <vscale x 1 x i64> %x,
+ <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 1, i64 0), <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer)
+ )
+ ret void
+}
+
declare i64 @llvm.vscale.i64()
declare void @llvm.masked.scatter.nxv1i64.nxv1p0(<vscale x 1 x i64>, <vscale x 1 x ptr>, i32, <vscale x 1 x i1>)
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>)
More information about the llvm-commits
mailing list