Skip to content

Commit 328c3a8

Browse files
[RISCV][VLOPT] Add vmerge to isSupportedInstr (#122340)
1 parent c492a22 commit 328c3a8

File tree

5 files changed

+66
-6
lines changed

5 files changed

+66
-6
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,10 @@ static bool isSupportedInstr(const MachineInstr &MI) {
944944
case RISCV::VMADD_VX:
945945
case RISCV::VNMSUB_VV:
946946
case RISCV::VNMSUB_VX:
947+
// Vector Integer Merge Instructions
948+
case RISCV::VMERGE_VIM:
949+
case RISCV::VMERGE_VVM:
950+
case RISCV::VMERGE_VXM:
947951
// Vector Widening Integer Multiply-Add Instructions
948952
case RISCV::VWMACCU_VV:
949953
case RISCV::VWMACCU_VX:

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ define void @buildvec_seq_v9i8(ptr %x) {
697697
; CHECK-LABEL: buildvec_seq_v9i8:
698698
; CHECK: # %bb.0:
699699
; CHECK-NEXT: li a1, 73
700-
; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
700+
; CHECK-NEXT: vsetivli zero, 9, e8, m1, ta, ma
701701
; CHECK-NEXT: vmv.v.i v9, 3
702702
; CHECK-NEXT: vsetvli zero, zero, e16, m2, ta, ma
703703
; CHECK-NEXT: vmv.s.x v0, a1
@@ -706,7 +706,6 @@ define void @buildvec_seq_v9i8(ptr %x) {
706706
; CHECK-NEXT: vsetvli zero, zero, e8, m1, ta, ma
707707
; CHECK-NEXT: vmerge.vim v9, v9, 1, v0
708708
; CHECK-NEXT: vmv1r.v v0, v8
709-
; CHECK-NEXT: vsetivli zero, 9, e8, m1, ta, ma
710709
; CHECK-NEXT: vmerge.vim v8, v9, 2, v0
711710
; CHECK-NEXT: vse8.v v8, (a0)
712711
; CHECK-NEXT: ret

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,10 +1290,8 @@ define void @mulhs_v6i16(ptr %x) {
12901290
; CHECK-NEXT: vle16.v v8, (a0)
12911291
; CHECK-NEXT: li a1, 22
12921292
; CHECK-NEXT: vmv.s.x v0, a1
1293-
; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
12941293
; CHECK-NEXT: vmv.v.i v9, -7
12951294
; CHECK-NEXT: vmerge.vim v9, v9, 7, v0
1296-
; CHECK-NEXT: vsetivli zero, 6, e16, m1, ta, ma
12971295
; CHECK-NEXT: vdiv.vv v8, v8, v9
12981296
; CHECK-NEXT: vse16.v v8, (a0)
12991297
; CHECK-NEXT: ret

llvm/test/CodeGen/RISCV/rvv/narrow-shift-extend.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,9 @@ entry:
142142
define <vscale x 4 x i32> @test_vloxei7(ptr %ptr, <vscale x 4 x i1> %offset, i64 %vl) {
143143
; CHECK-LABEL: test_vloxei7:
144144
; CHECK: # %bb.0: # %entry
145-
; CHECK-NEXT: vsetvli a2, zero, e64, m4, ta, ma
145+
; CHECK-NEXT: vsetvli zero, a1, e64, m4, ta, ma
146146
; CHECK-NEXT: vmv.v.i v8, 0
147147
; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
148-
; CHECK-NEXT: vsetvli zero, a1, e64, m4, ta, ma
149148
; CHECK-NEXT: vsll.vi v12, v8, 2
150149
; CHECK-NEXT: vsetvli zero, zero, e32, m2, ta, ma
151150
; CHECK-NEXT: vloxei64.v v8, (a0), v12

llvm/test/CodeGen/RISCV/rvv/vl-opt-instrs.ll

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3535,3 +3535,63 @@ define <vscale x 4 x i1> @vmfgt_vv(<vscale x 4 x float> %a, <vscale x 4 x i1> %b
35353535
%2 = call <vscale x 4 x i1> @llvm.riscv.vmand.nxv4i1(<vscale x 4 x i1> %1, <vscale x 4 x i1> %b, iXLen %vl)
35363536
ret <vscale x 4 x i1> %2
35373537
}
3538+
3539+
define <vscale x 4 x i32> @vmerge_vvm(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b, <vscale x 4 x i1> %c, iXLen %vl) {
3540+
; NOVLOPT-LABEL: vmerge_vvm:
3541+
; NOVLOPT: # %bb.0:
3542+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3543+
; NOVLOPT-NEXT: vmerge.vvm v8, v8, v10, v0
3544+
; NOVLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3545+
; NOVLOPT-NEXT: vadd.vv v8, v8, v10
3546+
; NOVLOPT-NEXT: ret
3547+
;
3548+
; VLOPT-LABEL: vmerge_vvm:
3549+
; VLOPT: # %bb.0:
3550+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3551+
; VLOPT-NEXT: vmerge.vvm v8, v8, v10, v0
3552+
; VLOPT-NEXT: vadd.vv v8, v8, v10
3553+
; VLOPT-NEXT: ret
3554+
%1 = call <vscale x 4 x i32> @llvm.riscv.vmerge.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b, <vscale x 4 x i1> %c, iXLen -1)
3555+
%2 = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %1, <vscale x 4 x i32> %b, iXLen %vl)
3556+
ret <vscale x 4 x i32> %2
3557+
}
3558+
3559+
define <vscale x 4 x i32> @vmerge_vxm(<vscale x 4 x i32> %a, i32 %b, <vscale x 4 x i1> %c, iXLen %vl) {
3560+
; NOVLOPT-LABEL: vmerge_vxm:
3561+
; NOVLOPT: # %bb.0:
3562+
; NOVLOPT-NEXT: vsetvli a2, zero, e32, m2, ta, ma
3563+
; NOVLOPT-NEXT: vmerge.vxm v8, v8, a0, v0
3564+
; NOVLOPT-NEXT: vsetvli zero, a1, e32, m2, ta, ma
3565+
; NOVLOPT-NEXT: vadd.vv v8, v8, v8
3566+
; NOVLOPT-NEXT: ret
3567+
;
3568+
; VLOPT-LABEL: vmerge_vxm:
3569+
; VLOPT: # %bb.0:
3570+
; VLOPT-NEXT: vsetvli zero, a1, e32, m2, ta, ma
3571+
; VLOPT-NEXT: vmerge.vxm v8, v8, a0, v0
3572+
; VLOPT-NEXT: vadd.vv v8, v8, v8
3573+
; VLOPT-NEXT: ret
3574+
%1 = call <vscale x 4 x i32> @llvm.riscv.vmerge.nxv4i32.i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %a, i32 %b, <vscale x 4 x i1> %c, iXLen -1)
3575+
%2 = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %1, <vscale x 4 x i32> %1, iXLen %vl)
3576+
ret <vscale x 4 x i32> %2
3577+
}
3578+
3579+
define <vscale x 4 x i32> @vmerge_vim(<vscale x 4 x i32> %a, <vscale x 4 x i1> %c, iXLen %vl) {
3580+
; NOVLOPT-LABEL: vmerge_vim:
3581+
; NOVLOPT: # %bb.0:
3582+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3583+
; NOVLOPT-NEXT: vmerge.vim v8, v8, 9, v0
3584+
; NOVLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3585+
; NOVLOPT-NEXT: vadd.vv v8, v8, v8
3586+
; NOVLOPT-NEXT: ret
3587+
;
3588+
; VLOPT-LABEL: vmerge_vim:
3589+
; VLOPT: # %bb.0:
3590+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3591+
; VLOPT-NEXT: vmerge.vim v8, v8, 9, v0
3592+
; VLOPT-NEXT: vadd.vv v8, v8, v8
3593+
; VLOPT-NEXT: ret
3594+
%1 = call <vscale x 4 x i32> @llvm.riscv.vmerge.nxv4i32.i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %a, i32 9, <vscale x 4 x i1> %c, iXLen -1)
3595+
%2 = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %1, <vscale x 4 x i32> %1, iXLen %vl)
3596+
ret <vscale x 4 x i32> %2
3597+
}

0 commit comments

Comments
 (0)