[llvm] e19bc76 - [RISCV] Precommit test coverage for pr118873
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 10:19:34 PST 2025
Author: Philip Reames
Date: 2025-01-15T10:18:56-08:00
New Revision: e19bc76812037abab7b6b14b7befbba366f541ce
URL: https://github.com/llvm/llvm-project/commit/e19bc76812037abab7b6b14b7befbba366f541ce
DIFF: https://github.com/llvm/llvm-project/commit/e19bc76812037abab7b6b14b7befbba366f541ce.diff
LOG: [RISCV] Precommit test coverage for pr118873
Added:
Modified:
llvm/test/CodeGen/RISCV/rvv/splat-vectors.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/RISCV/rvv/splat-vectors.ll b/llvm/test/CodeGen/RISCV/rvv/splat-vectors.ll
index 2e6df118401792..a556c3125c85db 100644
--- a/llvm/test/CodeGen/RISCV/rvv/splat-vectors.ll
+++ b/llvm/test/CodeGen/RISCV/rvv/splat-vectors.ll
@@ -105,3 +105,147 @@ define <vscale x 4 x float> @splat_idx_nxv4f32(<vscale x 4 x float> %v, i64 %idx
%splat = shufflevector <vscale x 4 x float> %ins, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
ret <vscale x 4 x float> %splat
}
+
+define <vscale x 8 x float> @splat_idx_nxv4f32_nxv8f32(<vscale x 4 x float> %v, i64 %idx) {
+; CHECK-LABEL: splat_idx_nxv4f32_nxv8f32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
+; CHECK-NEXT: vrgather.vx v12, v8, a0
+; CHECK-NEXT: vmv.v.v v8, v12
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 4 x float> %v, i64 %idx
+ %ins = insertelement <vscale x 8 x float> poison, float %x, i32 0
+ %splat = shufflevector <vscale x 8 x float> %ins, <vscale x 8 x float> poison, <vscale x 8 x i32> zeroinitializer
+ ret <vscale x 8 x float> %splat
+}
+
+define <vscale x 4 x float> @splat_idx_v4f32_nxv4f32(<4 x float> %v, i64 %idx) {
+; CHECK-LABEL: splat_idx_v4f32_nxv4f32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
+; CHECK-NEXT: vrgather.vx v10, v8, a0
+; CHECK-NEXT: vmv.v.v v8, v10
+; CHECK-NEXT: ret
+ %x = extractelement <4 x float> %v, i64 %idx
+ %ins = insertelement <vscale x 4 x float> poison, float %x, i32 0
+ %splat = shufflevector <vscale x 4 x float> %ins, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+ ret <vscale x 4 x float> %splat
+}
+
+; Negative test, scale could have a value > 2
+define <8 x float> @splat_idx_nxv4f32_v8f32(<vscale x 4 x float> %v, i64 %idx) {
+; CHECK-LABEL: splat_idx_nxv4f32_v8f32:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetivli zero, 1, e32, m2, ta, ma
+; CHECK-NEXT: vslidedown.vx v8, v8, a0
+; CHECK-NEXT: vfmv.f.s fa5, v8
+; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
+; CHECK-NEXT: vfmv.v.f v8, fa5
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 4 x float> %v, i64 %idx
+ %ins = insertelement <8 x float> poison, float %x, i32 0
+ %splat = shufflevector <8 x float> %ins, <8 x float> poison, <8 x i32> zeroinitializer
+ ret <8 x float> %splat
+}
+
+define <vscale x 4 x float> @splat_idx_nxv8f32_nxv4f32_constant_0(<vscale x 8 x float> %v) {
+; CHECK-LABEL: splat_idx_nxv8f32_nxv4f32_constant_0:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
+; CHECK-NEXT: vrgather.vi v10, v8, 0
+; CHECK-NEXT: vmv.v.v v8, v10
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 8 x float> %v, i64 0
+ %ins = insertelement <vscale x 4 x float> poison, float %x, i32 0
+ %splat = shufflevector <vscale x 4 x float> %ins, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+ ret <vscale x 4 x float> %splat
+}
+
+define <vscale x 4 x i8> @splat_idx_nxv8i8_nxv4i8_constant_0(<vscale x 8 x i8> %v) {
+; CHECK-LABEL: splat_idx_nxv8i8_nxv4i8_constant_0:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
+; CHECK-NEXT: vmv.x.s a0, v8
+; CHECK-NEXT: vmv.v.x v8, a0
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 8 x i8> %v, i64 0
+ %ins = insertelement <vscale x 4 x i8> poison, i8 %x, i32 0
+ %splat = shufflevector <vscale x 4 x i8> %ins, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
+ ret <vscale x 4 x i8> %splat
+}
+
+define <vscale x 4 x i8> @splat_idx_nxv8i8_nxv4i8_constant_3(<vscale x 8 x i8> %v) {
+; CHECK-LABEL: splat_idx_nxv8i8_nxv4i8_constant_3:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetivli zero, 1, e8, m1, ta, ma
+; CHECK-NEXT: vslidedown.vi v8, v8, 3
+; CHECK-NEXT: vmv.x.s a0, v8
+; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
+; CHECK-NEXT: vmv.v.x v8, a0
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 8 x i8> %v, i64 3
+ %ins = insertelement <vscale x 4 x i8> poison, i8 %x, i32 0
+ %splat = shufflevector <vscale x 4 x i8> %ins, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
+ ret <vscale x 4 x i8> %splat
+}
+
+
+; Negative test, vscale coule be 2
+define <vscale x 4 x i8> @splat_idx_nxv8i8_nxv4i8_constant_15(<vscale x 8 x i8> %v) {
+; CHECK-LABEL: splat_idx_nxv8i8_nxv4i8_constant_15:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetivli zero, 1, e8, m1, ta, ma
+; CHECK-NEXT: vslidedown.vi v8, v8, 15
+; CHECK-NEXT: vmv.x.s a0, v8
+; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
+; CHECK-NEXT: vmv.v.x v8, a0
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 8 x i8> %v, i64 15
+ %ins = insertelement <vscale x 4 x i8> poison, i8 %x, i32 0
+ %splat = shufflevector <vscale x 4 x i8> %ins, <vscale x 4 x i8> poison, <vscale x 4 x i32> zeroinitializer
+ ret <vscale x 4 x i8> %splat
+}
+
+define <8 x float> @splat_idx_nxv4f32_v8f32_constant_0(<vscale x 4 x float> %v) {
+; CHECK-LABEL: splat_idx_nxv4f32_v8f32_constant_0:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
+; CHECK-NEXT: vfmv.f.s fa5, v8
+; CHECK-NEXT: vfmv.v.f v8, fa5
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 4 x float> %v, i64 0
+ %ins = insertelement <8 x float> poison, float %x, i32 0
+ %splat = shufflevector <8 x float> %ins, <8 x float> poison, <8 x i32> zeroinitializer
+ ret <8 x float> %splat
+}
+
+define <8 x float> @splat_idx_nxv4f32_v8f32_constant_7(<vscale x 4 x float> %v) {
+; CHECK-LABEL: splat_idx_nxv4f32_v8f32_constant_7:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetivli zero, 1, e32, m2, ta, ma
+; CHECK-NEXT: vslidedown.vi v8, v8, 7
+; CHECK-NEXT: vfmv.f.s fa5, v8
+; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
+; CHECK-NEXT: vfmv.v.f v8, fa5
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 4 x float> %v, i64 7
+ %ins = insertelement <8 x float> poison, float %x, i32 0
+ %splat = shufflevector <8 x float> %ins, <8 x float> poison, <8 x i32> zeroinitializer
+ ret <8 x float> %splat
+}
+
+; Negative test, vscale might be 4
+define <8 x float> @splat_idx_nxv4f32_v8f32_constant_8(<vscale x 4 x float> %v) {
+; CHECK-LABEL: splat_idx_nxv4f32_v8f32_constant_8:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vsetivli zero, 1, e32, m2, ta, ma
+; CHECK-NEXT: vslidedown.vi v8, v8, 8
+; CHECK-NEXT: vfmv.f.s fa5, v8
+; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
+; CHECK-NEXT: vfmv.v.f v8, fa5
+; CHECK-NEXT: ret
+ %x = extractelement <vscale x 4 x float> %v, i64 8
+ %ins = insertelement <8 x float> poison, float %x, i32 0
+ %splat = shufflevector <8 x float> %ins, <8 x float> poison, <8 x i32> zeroinitializer
+ ret <8 x float> %splat
+}
More information about the llvm-commits
mailing list