Skip to content

Commit d0373db

Browse files
[RISCV][VLOPT] Add vadc to isSupportedInstr (#122345)
1 parent 04e54cc commit d0373db

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
@@ -948,6 +948,10 @@ static bool isSupportedInstr(const MachineInstr &MI) {
948948
case RISCV::VMERGE_VIM:
949949
case RISCV::VMERGE_VVM:
950950
case RISCV::VMERGE_VXM:
951+
// Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions
952+
case RISCV::VADC_VIM:
953+
case RISCV::VADC_VVM:
954+
case RISCV::VADC_VXM:
951955
// Vector Widening Integer Multiply-Add Instructions
952956
case RISCV::VWMACCU_VV:
953957
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
@@ -3596,6 +3596,66 @@ define <vscale x 4 x i32> @vmerge_vim(<vscale x 4 x i32> %a, <vscale x 4 x i1> %
35963596
ret <vscale x 4 x i32> %2
35973597
}
35983598

3599+
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) {
3600+
; NOVLOPT-LABEL: vadc_vvm:
3601+
; NOVLOPT: # %bb.0:
3602+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3603+
; NOVLOPT-NEXT: vadc.vvm v8, v8, v10, v0
3604+
; NOVLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3605+
; NOVLOPT-NEXT: vadd.vv v8, v8, v10
3606+
; NOVLOPT-NEXT: ret
3607+
;
3608+
; VLOPT-LABEL: vadc_vvm:
3609+
; VLOPT: # %bb.0:
3610+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3611+
; VLOPT-NEXT: vadc.vvm v8, v8, v10, v0
3612+
; VLOPT-NEXT: vadd.vv v8, v8, v10
3613+
; VLOPT-NEXT: ret
3614+
%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)
3615+
%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)
3616+
ret <vscale x 4 x i32> %2
3617+
}
3618+
3619+
define <vscale x 4 x i32> @vadc_vxm(<vscale x 4 x i32> %a, i32 %b, <vscale x 4 x i1> %c, iXLen %vl) {
3620+
; NOVLOPT-LABEL: vadc_vxm:
3621+
; NOVLOPT: # %bb.0:
3622+
; NOVLOPT-NEXT: vsetvli a2, zero, e32, m2, ta, ma
3623+
; NOVLOPT-NEXT: vadc.vxm v8, v8, a0, v0
3624+
; NOVLOPT-NEXT: vsetvli zero, a1, e32, m2, ta, ma
3625+
; NOVLOPT-NEXT: vadd.vv v8, v8, v8
3626+
; NOVLOPT-NEXT: ret
3627+
;
3628+
; VLOPT-LABEL: vadc_vxm:
3629+
; VLOPT: # %bb.0:
3630+
; VLOPT-NEXT: vsetvli zero, a1, e32, m2, ta, ma
3631+
; VLOPT-NEXT: vadc.vxm v8, v8, a0, v0
3632+
; VLOPT-NEXT: vadd.vv v8, v8, v8
3633+
; VLOPT-NEXT: ret
3634+
%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)
3635+
%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)
3636+
ret <vscale x 4 x i32> %2
3637+
}
3638+
3639+
define <vscale x 4 x i32> @vadc_vim(<vscale x 4 x i32> %a, <vscale x 4 x i1> %c, iXLen %vl) {
3640+
; NOVLOPT-LABEL: vadc_vim:
3641+
; NOVLOPT: # %bb.0:
3642+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3643+
; NOVLOPT-NEXT: vadc.vim v8, v8, 9, v0
3644+
; NOVLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3645+
; NOVLOPT-NEXT: vadd.vv v8, v8, v8
3646+
; NOVLOPT-NEXT: ret
3647+
;
3648+
; VLOPT-LABEL: vadc_vim:
3649+
; VLOPT: # %bb.0:
3650+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3651+
; VLOPT-NEXT: vadc.vim v8, v8, 9, v0
3652+
; VLOPT-NEXT: vadd.vv v8, v8, v8
3653+
; VLOPT-NEXT: ret
3654+
%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)
3655+
%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)
3656+
ret <vscale x 4 x i32> %2
3657+
}
3658+
35993659
define <vscale x 4 x i32> @vaadd_vv(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b, iXLen %vl) {
36003660
; NOVLOPT-LABEL: vaadd_vv:
36013661
; NOVLOPT: # %bb.0:

0 commit comments

Comments
 (0)