Skip to content

Commit 5f70fea

Browse files
[RISCV][VLOPT] Add Vector Floating-Point Compare Instructions to getSupportedInstr
1 parent b419ede commit 5f70fea

File tree

2 files changed

+211
-0
lines changed

2 files changed

+211
-0
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,17 @@ static bool isSupportedInstr(const MachineInstr &MI) {
10071007
// Vector Widening Floating-Point Multiply
10081008
case RISCV::VFWMUL_VF:
10091009
case RISCV::VFWMUL_VV:
1010+
// Vector Floating-Point Compare Instructions
1011+
case RISCV::VMFEQ_VF:
1012+
case RISCV::VMFEQ_VV:
1013+
case RISCV::VMFNE_VF:
1014+
case RISCV::VMFNE_VV:
1015+
case RISCV::VMFLT_VF:
1016+
case RISCV::VMFLT_VV:
1017+
case RISCV::VMFLE_VF:
1018+
case RISCV::VMFLE_VV:
1019+
case RISCV::VMFGT_VF:
1020+
case RISCV::VMFGE_VF:
10101021
// Single-Width Floating-Point/Integer Type-Convert Instructions
10111022
case RISCV::VFCVT_XU_F_V:
10121023
case RISCV::VFCVT_X_F_V:

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

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3335,3 +3335,203 @@ define <vscale x 4 x double> @vfwmul_vf(<vscale x 4 x float> %a, float %b, iXLen
33353335
%2 = call <vscale x 4 x double> @llvm.riscv.vfadd.nxv4f64.nxv4f64(<vscale x 4 x double> poison, <vscale x 4 x double> %1, <vscale x 4 x double> %1, iXLen 7, iXLen %vl)
33363336
ret <vscale x 4 x double> %2
33373337
}
3338+
3339+
define <vscale x 4 x i1> @vmfeq_vf(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, float%c, iXLen %vl) {
3340+
; NOVLOPT-LABEL: vmfeq_vf:
3341+
; NOVLOPT: # %bb.0:
3342+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3343+
; NOVLOPT-NEXT: vmfeq.vf v10, v8, fa0
3344+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3345+
; NOVLOPT-NEXT: vmand.mm v0, v10, v0
3346+
; NOVLOPT-NEXT: ret
3347+
;
3348+
; VLOPT-LABEL: vmfeq_vf:
3349+
; VLOPT: # %bb.0:
3350+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3351+
; VLOPT-NEXT: vmfeq.vf v10, v8, fa0
3352+
; VLOPT-NEXT: vmand.mm v0, v10, v0
3353+
; VLOPT-NEXT: ret
3354+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfeq.nxv4f32.f32(<vscale x 4 x float> %a, float %c, iXLen -1)
3355+
%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)
3356+
ret <vscale x 4 x i1> %2
3357+
}
3358+
3359+
define <vscale x 4 x i1> @vmfeq_vv(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, <vscale x 4 x float> %c, iXLen %vl) {
3360+
; NOVLOPT-LABEL: vmfeq_vv:
3361+
; NOVLOPT: # %bb.0:
3362+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3363+
; NOVLOPT-NEXT: vmfeq.vv v12, v8, v10
3364+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3365+
; NOVLOPT-NEXT: vmand.mm v0, v12, v0
3366+
; NOVLOPT-NEXT: ret
3367+
;
3368+
; VLOPT-LABEL: vmfeq_vv:
3369+
; VLOPT: # %bb.0:
3370+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3371+
; VLOPT-NEXT: vmfeq.vv v12, v8, v10
3372+
; VLOPT-NEXT: vmand.mm v0, v12, v0
3373+
; VLOPT-NEXT: ret
3374+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfeq.nxv4f32.nxv4f32(<vscale x 4 x float> %a, <vscale x 4 x float> %c, iXLen -1)
3375+
%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)
3376+
ret <vscale x 4 x i1> %2
3377+
}
3378+
3379+
define <vscale x 4 x i1> @vmfne_vf(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, float%c, iXLen %vl) {
3380+
; NOVLOPT-LABEL: vmfne_vf:
3381+
; NOVLOPT: # %bb.0:
3382+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3383+
; NOVLOPT-NEXT: vmfne.vf v10, v8, fa0
3384+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3385+
; NOVLOPT-NEXT: vmand.mm v0, v10, v0
3386+
; NOVLOPT-NEXT: ret
3387+
;
3388+
; VLOPT-LABEL: vmfne_vf:
3389+
; VLOPT: # %bb.0:
3390+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3391+
; VLOPT-NEXT: vmfne.vf v10, v8, fa0
3392+
; VLOPT-NEXT: vmand.mm v0, v10, v0
3393+
; VLOPT-NEXT: ret
3394+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfne.nxv4f32.f32(<vscale x 4 x float> %a, float %c, iXLen -1)
3395+
%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)
3396+
ret <vscale x 4 x i1> %2
3397+
}
3398+
3399+
define <vscale x 4 x i1> @vmfne_vv(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, <vscale x 4 x float> %c, iXLen %vl) {
3400+
; NOVLOPT-LABEL: vmfne_vv:
3401+
; NOVLOPT: # %bb.0:
3402+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3403+
; NOVLOPT-NEXT: vmfne.vv v12, v8, v10
3404+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3405+
; NOVLOPT-NEXT: vmand.mm v0, v12, v0
3406+
; NOVLOPT-NEXT: ret
3407+
;
3408+
; VLOPT-LABEL: vmfne_vv:
3409+
; VLOPT: # %bb.0:
3410+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3411+
; VLOPT-NEXT: vmfne.vv v12, v8, v10
3412+
; VLOPT-NEXT: vmand.mm v0, v12, v0
3413+
; VLOPT-NEXT: ret
3414+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfne.nxv4f32.nxv4f32(<vscale x 4 x float> %a, <vscale x 4 x float> %c, iXLen -1)
3415+
%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)
3416+
ret <vscale x 4 x i1> %2
3417+
}
3418+
3419+
define <vscale x 4 x i1> @vmflt_vf(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, float%c, iXLen %vl) {
3420+
; NOVLOPT-LABEL: vmflt_vf:
3421+
; NOVLOPT: # %bb.0:
3422+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3423+
; NOVLOPT-NEXT: vmflt.vf v10, v8, fa0
3424+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3425+
; NOVLOPT-NEXT: vmand.mm v0, v10, v0
3426+
; NOVLOPT-NEXT: ret
3427+
;
3428+
; VLOPT-LABEL: vmflt_vf:
3429+
; VLOPT: # %bb.0:
3430+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3431+
; VLOPT-NEXT: vmflt.vf v10, v8, fa0
3432+
; VLOPT-NEXT: vmand.mm v0, v10, v0
3433+
; VLOPT-NEXT: ret
3434+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmflt.nxv4f32.f32(<vscale x 4 x float> %a, float %c, iXLen -1)
3435+
%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)
3436+
ret <vscale x 4 x i1> %2
3437+
}
3438+
3439+
define <vscale x 4 x i1> @vmflt_vv(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, <vscale x 4 x float> %c, iXLen %vl) {
3440+
; NOVLOPT-LABEL: vmflt_vv:
3441+
; NOVLOPT: # %bb.0:
3442+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3443+
; NOVLOPT-NEXT: vmflt.vv v12, v8, v10
3444+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3445+
; NOVLOPT-NEXT: vmand.mm v0, v12, v0
3446+
; NOVLOPT-NEXT: ret
3447+
;
3448+
; VLOPT-LABEL: vmflt_vv:
3449+
; VLOPT: # %bb.0:
3450+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3451+
; VLOPT-NEXT: vmflt.vv v12, v8, v10
3452+
; VLOPT-NEXT: vmand.mm v0, v12, v0
3453+
; VLOPT-NEXT: ret
3454+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmflt.nxv4f32.nxv4f32(<vscale x 4 x float> %a, <vscale x 4 x float> %c, iXLen -1)
3455+
%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)
3456+
ret <vscale x 4 x i1> %2
3457+
}
3458+
3459+
define <vscale x 4 x i1> @vmfle_vf(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, float%c, iXLen %vl) {
3460+
; NOVLOPT-LABEL: vmfle_vf:
3461+
; NOVLOPT: # %bb.0:
3462+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3463+
; NOVLOPT-NEXT: vmfle.vf v10, v8, fa0
3464+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3465+
; NOVLOPT-NEXT: vmand.mm v0, v10, v0
3466+
; NOVLOPT-NEXT: ret
3467+
;
3468+
; VLOPT-LABEL: vmfle_vf:
3469+
; VLOPT: # %bb.0:
3470+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3471+
; VLOPT-NEXT: vmfle.vf v10, v8, fa0
3472+
; VLOPT-NEXT: vmand.mm v0, v10, v0
3473+
; VLOPT-NEXT: ret
3474+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfle.nxv4f32.f32(<vscale x 4 x float> %a, float %c, iXLen -1)
3475+
%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)
3476+
ret <vscale x 4 x i1> %2
3477+
}
3478+
3479+
define <vscale x 4 x i1> @vmfle_vv(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, <vscale x 4 x float> %c, iXLen %vl) {
3480+
; NOVLOPT-LABEL: vmfle_vv:
3481+
; NOVLOPT: # %bb.0:
3482+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3483+
; NOVLOPT-NEXT: vmfle.vv v12, v8, v10
3484+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3485+
; NOVLOPT-NEXT: vmand.mm v0, v12, v0
3486+
; NOVLOPT-NEXT: ret
3487+
;
3488+
; VLOPT-LABEL: vmfle_vv:
3489+
; VLOPT: # %bb.0:
3490+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3491+
; VLOPT-NEXT: vmfle.vv v12, v8, v10
3492+
; VLOPT-NEXT: vmand.mm v0, v12, v0
3493+
; VLOPT-NEXT: ret
3494+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfle.nxv4f32.nxv4f32(<vscale x 4 x float> %a, <vscale x 4 x float> %c, iXLen -1)
3495+
%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)
3496+
ret <vscale x 4 x i1> %2
3497+
}
3498+
3499+
define <vscale x 4 x i1> @vmfgt_vf(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, float%c, iXLen %vl) {
3500+
; NOVLOPT-LABEL: vmfgt_vf:
3501+
; NOVLOPT: # %bb.0:
3502+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3503+
; NOVLOPT-NEXT: vmfgt.vf v10, v8, fa0
3504+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3505+
; NOVLOPT-NEXT: vmand.mm v0, v10, v0
3506+
; NOVLOPT-NEXT: ret
3507+
;
3508+
; VLOPT-LABEL: vmfgt_vf:
3509+
; VLOPT: # %bb.0:
3510+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3511+
; VLOPT-NEXT: vmfgt.vf v10, v8, fa0
3512+
; VLOPT-NEXT: vmand.mm v0, v10, v0
3513+
; VLOPT-NEXT: ret
3514+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfgt.nxv4f32.f32(<vscale x 4 x float> %a, float %c, iXLen -1)
3515+
%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)
3516+
ret <vscale x 4 x i1> %2
3517+
}
3518+
3519+
define <vscale x 4 x i1> @vmfgt_vv(<vscale x 4 x float> %a, <vscale x 4 x i1> %b, <vscale x 4 x float> %c, iXLen %vl) {
3520+
; NOVLOPT-LABEL: vmfgt_vv:
3521+
; NOVLOPT: # %bb.0:
3522+
; NOVLOPT-NEXT: vsetvli a1, zero, e32, m2, ta, ma
3523+
; NOVLOPT-NEXT: vmflt.vv v12, v10, v8
3524+
; NOVLOPT-NEXT: vsetvli zero, a0, e8, mf2, ta, ma
3525+
; NOVLOPT-NEXT: vmand.mm v0, v12, v0
3526+
; NOVLOPT-NEXT: ret
3527+
;
3528+
; VLOPT-LABEL: vmfgt_vv:
3529+
; VLOPT: # %bb.0:
3530+
; VLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3531+
; VLOPT-NEXT: vmflt.vv v12, v10, v8
3532+
; VLOPT-NEXT: vmand.mm v0, v12, v0
3533+
; VLOPT-NEXT: ret
3534+
%1 = call <vscale x 4 x i1> @llvm.riscv.vmfgt.nxv4f32.nxv4f32(<vscale x 4 x float> %a, <vscale x 4 x float> %c, iXLen -1)
3535+
%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)
3536+
ret <vscale x 4 x i1> %2
3537+
}

0 commit comments

Comments
 (0)