@@ -2373,29 +2373,41 @@ defm : VPatAVGADDVL_VV_VX_RM<riscv_avgflooru_vl, 0b10>;
23732373defm : VPatAVGADDVL_VV_VX_RM<riscv_avgceilu_vl, 0b00>;
23742374
23752375// 12.5. Vector Narrowing Fixed-Point Clip Instructions
2376- class VPatTruncSatClipMaxMinVLBase<VTypeInfo vti,
2377- VTypeInfo wti,
2378- SDPatternOperator op1,
2379- int op1_value,
2380- SDPatternOperator op2,
2381- int op2_value> :
2382- Pat<(vti.Vector (riscv_trunc_vector_vl
2383- (wti.Vector (op1
2384- (wti.Vector (op2
2376+ multiclass VPatTruncSatClipVL<VTypeInfo vti, VTypeInfo wti> {
2377+ defvar sew = vti.SEW;
2378+ defvar uminval = !sub(!shl(1, sew), 1);
2379+ defvar sminval = !sub(!shl(1, !sub(sew, 1)), 1);
2380+ defvar smaxval = !sub(0, !shl(1, !sub(sew, 1)));
2381+
2382+ let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
2383+ GetVTypePredicates<wti>.Predicates) in {
2384+ def : Pat<(vti.Vector (riscv_trunc_vector_vl
2385+ (wti.Vector (riscv_smin_vl
2386+ (wti.Vector (riscv_smax_vl
2387+ (wti.Vector wti.RegClass:$rs1),
2388+ (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), smaxval, (XLenVT srcvalue))),
2389+ (wti.Vector undef),(wti.Mask V0), VLOpFrag)),
2390+ (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), sminval, (XLenVT srcvalue))),
2391+ (wti.Vector undef), (wti.Mask V0), VLOpFrag)),
2392+ (vti.Mask V0), VLOpFrag)),
2393+ (!cast<Instruction>("PseudoVNCLIP_WI_"#vti.LMul.MX#"_MASK")
2394+ (vti.Vector (IMPLICIT_DEF)), wti.RegClass:$rs1, 0,
2395+ (vti.Mask V0), 0, GPR:$vl, vti.Log2SEW, TA_MA)>;
2396+
2397+ def : Pat<(vti.Vector (riscv_trunc_vector_vl
2398+ (wti.Vector (riscv_smax_vl
2399+ (wti.Vector (riscv_smin_vl
23852400 (wti.Vector wti.RegClass:$rs1),
2386- (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), op2_value , (XLenVT srcvalue))),
2401+ (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), sminval , (XLenVT srcvalue))),
23872402 (wti.Vector undef),(wti.Mask V0), VLOpFrag)),
2388- (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), op1_value , (XLenVT srcvalue))),
2403+ (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), smaxval , (XLenVT srcvalue))),
23892404 (wti.Vector undef), (wti.Mask V0), VLOpFrag)),
23902405 (vti.Mask V0), VLOpFrag)),
23912406 (!cast<Instruction>("PseudoVNCLIP_WI_"#vti.LMul.MX#"_MASK")
23922407 (vti.Vector (IMPLICIT_DEF)), wti.RegClass:$rs1, 0,
23932408 (vti.Mask V0), 0, GPR:$vl, vti.Log2SEW, TA_MA)>;
23942409
2395- class VPatTruncSatClipUMinVL<VTypeInfo vti,
2396- VTypeInfo wti,
2397- int uminval> :
2398- Pat<(vti.Vector (riscv_trunc_vector_vl
2410+ def : Pat<(vti.Vector (riscv_trunc_vector_vl
23992411 (wti.Vector (riscv_umin_vl
24002412 (wti.Vector wti.RegClass:$rs1),
24012413 (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), uminval, (XLenVT srcvalue))),
@@ -2404,25 +2416,7 @@ class VPatTruncSatClipUMinVL<VTypeInfo vti,
24042416 (!cast<Instruction>("PseudoVNCLIPU_WI_"#vti.LMul.MX#"_MASK")
24052417 (vti.Vector (IMPLICIT_DEF)), wti.RegClass:$rs1, 0,
24062418 (vti.Mask V0), 0, GPR:$vl, vti.Log2SEW, TA_MA)>;
2407-
2408- multiclass VPatTruncSatClipMaxMinVL<VTypeInfo vti, VTypeInfo wti,
2409- SDPatternOperator max, int maxval, SDPatternOperator min, int minval> {
2410- def : VPatTruncSatClipMaxMinVLBase<vti, wti, max, maxval, min, minval>;
2411- def : VPatTruncSatClipMaxMinVLBase<vti, wti, min, minval, max, maxval>;
2412- }
2413-
2414- multiclass VPatTruncSatClipVL<VTypeInfo vti, VTypeInfo wti> {
2415- defvar sew = vti.SEW;
2416- defvar uminval = !sub(!shl(1, sew), 1);
2417- defvar sminval = !sub(!shl(1, !sub(sew, 1)), 1);
2418- defvar smaxval = !sub(0, !shl(1, !sub(sew, 1)));
2419-
2420- let Predicates = !listconcat(GetVTypePredicates<vti>.Predicates,
2421- GetVTypePredicates<wti>.Predicates) in {
2422- defm : VPatTruncSatClipMaxMinVL<vti, wti, riscv_smin_vl, sminval, riscv_smax_vl, smaxval>;
2423- def : VPatTruncSatClipUMinVL<vti, wti, uminval>;
24242419 }
2425-
24262420}
24272421
24282422foreach vtiToWti = AllWidenableIntVectors in
0 commit comments