Skip to content

Commit 3b9a367

Browse files
committed
[RISCV Add some vsetvli insertion test cases with vmv.s.x+reduction. NFC
These test cases where intended to get a single vsetvli by using the vmv.s.x intrinsic with the same LMUL as the reduction. This works for FP, but does not work for integer. I believe llvm#71501 will break this for FP too. Hopefully the vsetvli pass can be taught to fix this.
1 parent 1c58a6b commit 3b9a367

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

+35
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,41 @@ define void @add_v16i64(ptr %x, ptr %y) vscale_range(2,2) {
627627
ret void
628628
}
629629

630+
define <vscale x 2 x float> @fp_reduction_vfmv_s_f(float %0, <vscale x 8 x float> %1, i64 %2) {
631+
; CHECK-LABEL: fp_reduction_vfmv_s_f:
632+
; CHECK: # %bb.0:
633+
; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
634+
; CHECK-NEXT: vfmv.s.f v12, fa0
635+
; CHECK-NEXT: vfredusum.vs v8, v8, v12
636+
; CHECK-NEXT: ret
637+
%4 = tail call <vscale x 8 x float> @llvm.riscv.vfmv.s.f.nxv8f32.i64(<vscale x 8 x float> poison, float %0, i64 %2)
638+
%5 = tail call <vscale x 2 x float> @llvm.vector.extract.nxv2f32.nxv8f32(<vscale x 8 x float> %4, i64 0)
639+
%6 = tail call <vscale x 2 x float> @llvm.riscv.vfredusum.nxv2f32.nxv8f32.i64(<vscale x 2 x float> poison, <vscale x 8 x float> %1, <vscale x 2 x float> %5, i64 7, i64 %2)
640+
ret <vscale x 2 x float> %6
641+
}
642+
643+
define dso_local <vscale x 2 x i32> @int_reduction_vmv_s_x(i32 signext %0, <vscale x 8 x i32> %1, i64 %2) {
644+
; CHECK-LABEL: int_reduction_vmv_s_x:
645+
; CHECK: # %bb.0:
646+
; CHECK-NEXT: vsetvli zero, a1, e32, m1, ta, ma
647+
; CHECK-NEXT: vmv.s.x v12, a0
648+
; CHECK-NEXT: vsetvli zero, a1, e32, m4, ta, ma
649+
; CHECK-NEXT: vredsum.vs v8, v8, v12
650+
; CHECK-NEXT: ret
651+
%4 = tail call <vscale x 8 x i32> @llvm.riscv.vmv.s.x.nxv8i32.i64(<vscale x 8 x i32> poison, i32 %0, i64 %2)
652+
%5 = tail call <vscale x 2 x i32> @llvm.vector.extract.nxv2i32.nxv8i32(<vscale x 8 x i32> %4, i64 0)
653+
%6 = tail call <vscale x 2 x i32> @llvm.riscv.vredsum.nxv2i32.nxv8i32.i64(<vscale x 2 x i32> poison, <vscale x 8 x i32> %1, <vscale x 2 x i32> %5, i64 %2)
654+
ret <vscale x 2 x i32> %6
655+
}
656+
657+
declare <vscale x 8 x float> @llvm.riscv.vfmv.s.f.nxv8f32.i64(<vscale x 8 x float>, float, i64)
658+
declare <vscale x 2 x float> @llvm.vector.extract.nxv2f32.nxv8f32(<vscale x 8 x float>, i64)
659+
declare <vscale x 2 x float> @llvm.riscv.vfredusum.nxv2f32.nxv8f32.i64(<vscale x 2 x float>, <vscale x 8 x float>, <vscale x 2 x float>, i64, i64)
660+
661+
declare <vscale x 8 x i32> @llvm.riscv.vmv.s.x.nxv8i32.i64(<vscale x 8 x i32>, i32, i64) #1
662+
declare <vscale x 2 x i32> @llvm.vector.extract.nxv2i32.nxv8i32(<vscale x 8 x i32>, i64 immarg) #2
663+
declare <vscale x 2 x i32> @llvm.riscv.vredsum.nxv2i32.nxv8i32.i64(<vscale x 2 x i32>, <vscale x 8 x i32>, <vscale x 2 x i32>, i64) #1
664+
630665
declare <vscale x 1 x i64> @llvm.riscv.vadd.mask.nxv1i64.nxv1i64(
631666
<vscale x 1 x i64>,
632667
<vscale x 1 x i64>,

0 commit comments

Comments
 (0)