Skip to content

Commit 2521b75

Browse files
[RISCV][VLOPT] Add vadcto isSupportedInstr
1 parent 5f70fea commit 2521b75

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
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 Add-with-Carry / Subtract-with-Borrow Instructions
948+
case RISCV::VADC_VIM:
949+
case RISCV::VADC_VVM:
950+
case RISCV::VADC_VXM:
947951
// Vector Widening Integer Multiply-Add Instructions
948952
case RISCV::VWMACCU_VV:
949953
case RISCV::VWMACCU_VX:

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> @vadc_vvm(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b, <vscale x 4 x i1> %c, iXLen %vl) {
3540+
; NOVLOPT-LABEL: vadc_vvm:
3541+
; NOVLOPT: # %bb.0:
3542+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3543+
; NOVLOPT-NEXT: vadc.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: vadc_vvm:
3549+
; VLOPT: # %bb.0:
3550+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3551+
; VLOPT-NEXT: vadc.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.vadc.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> @vadc_vxm(<vscale x 4 x i32> %a, i32 %b, <vscale x 4 x i1> %c, iXLen %vl) {
3560+
; NOVLOPT-LABEL: vadc_vxm:
3561+
; NOVLOPT: # %bb.0:
3562+
; NOVLOPT-NEXT: vsetvli a2, zero, e32, m2, ta, ma
3563+
; NOVLOPT-NEXT: vadc.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: vadc_vxm:
3569+
; VLOPT: # %bb.0:
3570+
; VLOPT-NEXT: vsetvli zero, a1, e32, m2, ta, ma
3571+
; VLOPT-NEXT: vadc.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.vadc.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> @vadc_vim(<vscale x 4 x i32> %a, <vscale x 4 x i1> %c, iXLen %vl) {
3580+
; NOVLOPT-LABEL: vadc_vim:
3581+
; NOVLOPT: # %bb.0:
3582+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3583+
; NOVLOPT-NEXT: vadc.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: vadc_vim:
3589+
; VLOPT: # %bb.0:
3590+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3591+
; VLOPT-NEXT: vadc.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.vadc.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)