From 2da8ed3d78bb4c4ba5548ae5b386f545ab2cc8b5 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Mon, 27 Mar 2023 17:02:16 +0100 Subject: [PATCH] [RISCV] Add tests for gather scatter pass for non-recursive mul strides Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D146982 --- llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll b/llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll index be151e4..31fcf10 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 @gather_loopless(ptr %p, i64 %stride) { +; CHECK-LABEL: @gather_loopless( +; CHECK-NEXT: [[STEP:%.*]] = call @llvm.experimental.stepvector.nxv1i64() +; CHECK-NEXT: [[SPLAT_INSERT:%.*]] = insertelement poison, i64 [[STRIDE:%.*]], i64 0 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector [[SPLAT_INSERT]], poison, zeroinitializer +; CHECK-NEXT: [[OFFSETS:%.*]] = mul [[STEP]], [[SPLAT]] +; CHECK-NEXT: [[PTRS:%.*]] = getelementptr i32, ptr [[P:%.*]], [[OFFSETS]] +; CHECK-NEXT: [[X:%.*]] = call @llvm.masked.gather.nxv1i64.nxv1p0( [[PTRS]], i32 8, shufflevector ( insertelement ( poison, i1 true, i64 0), poison, zeroinitializer), poison) +; CHECK-NEXT: ret [[X]] +; + %step = call @llvm.experimental.stepvector.nxv1i64() + %splat.insert = insertelement poison, i64 %stride, i64 0 + %splat = shufflevector %splat.insert, poison, zeroinitializer + %offsets = mul %step, %splat + %ptrs = getelementptr i32, ptr %p, %offsets + %x = call @llvm.masked.gather.nxv1i64.nxv1p0( + %ptrs, + i32 8, + shufflevector ( insertelement ( poison, i1 1, i64 0), poison, zeroinitializer), + poison + ) + ret %x +} + +define void @scatter_loopless( %x, ptr %p, i64 %stride) { +; CHECK-LABEL: @scatter_loopless( +; CHECK-NEXT: [[STEP:%.*]] = call @llvm.experimental.stepvector.nxv1i64() +; CHECK-NEXT: [[SPLAT_INSERT:%.*]] = insertelement poison, i64 [[STRIDE:%.*]], i64 0 +; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector [[SPLAT_INSERT]], poison, zeroinitializer +; CHECK-NEXT: [[OFFSETS:%.*]] = mul [[STEP]], [[SPLAT]] +; CHECK-NEXT: [[PTRS:%.*]] = getelementptr i32, ptr [[P:%.*]], [[OFFSETS]] +; CHECK-NEXT: call void @llvm.masked.scatter.nxv1i64.nxv1p0( [[X:%.*]], [[PTRS]], i32 8, shufflevector ( insertelement ( poison, i1 true, i64 0), poison, zeroinitializer)) +; CHECK-NEXT: ret void +; + %step = call @llvm.experimental.stepvector.nxv1i64() + %splat.insert = insertelement poison, i64 %stride, i64 0 + %splat = shufflevector %splat.insert, poison, zeroinitializer + %offsets = mul %step, %splat + %ptrs = getelementptr i32, ptr %p, %offsets + call void @llvm.masked.scatter.nxv1i64.nxv1p0( + %x, + %ptrs, + i32 8, + shufflevector ( insertelement ( poison, i1 1, i64 0), poison, zeroinitializer) + ) + ret void +} + declare i64 @llvm.vscale.i64() declare void @llvm.masked.scatter.nxv1i64.nxv1p0(, , i32, ) declare @llvm.masked.gather.nxv1i64.nxv1p0(, i32, , ) -- 2.7.4