@@ -36,6 +36,18 @@ def SDT_RISCVIntBinOp_VL : SDTypeProfile<1, 5, [SDTCisSameAs<0, 1>,
36
36
SDTCisSameNumEltsAs<0, 4>,
37
37
SDTCisVT<5, XLenVT>]>;
38
38
39
+ // Input: (vector, vector/scalar, merge, mask, roundmode, vl)
40
+ def SDT_RISCVVNBinOp_RM_VL : SDTypeProfile<1, 6, [SDTCisVec<0>, SDTCisInt<0>,
41
+ SDTCisSameAs<0, 3>,
42
+ SDTCisSameNumEltsAs<0, 1>,
43
+ SDTCisVec<1>,
44
+ SDTCisOpSmallerThanOp<2, 1>,
45
+ SDTCisSameAs<0, 2>,
46
+ SDTCisSameNumEltsAs<0, 4>,
47
+ SDTCVecEltisVT<4, i1>,
48
+ SDTCisVT<5, XLenVT>,
49
+ SDTCisVT<6, XLenVT>]>;
50
+
39
51
def SDT_RISCVFPUnOp_VL : SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>,
40
52
SDTCisVec<0>, SDTCisFP<0>,
41
53
SDTCVecEltisVT<2, i1>,
@@ -120,6 +132,9 @@ def riscv_uaddsat_vl : SDNode<"RISCVISD::UADDSAT_VL", SDT_RISCVIntBinOp_VL, [S
120
132
def riscv_ssubsat_vl : SDNode<"RISCVISD::SSUBSAT_VL", SDT_RISCVIntBinOp_VL>;
121
133
def riscv_usubsat_vl : SDNode<"RISCVISD::USUBSAT_VL", SDT_RISCVIntBinOp_VL>;
122
134
135
+ def riscv_vnclipu_vl : SDNode<"RISCVISD::VNCLIPU_VL", SDT_RISCVVNBinOp_RM_VL>;
136
+ def riscv_vnclip_vl : SDNode<"RISCVISD::VNCLIP_VL", SDT_RISCVVNBinOp_RM_VL>;
137
+
123
138
def riscv_fadd_vl : SDNode<"RISCVISD::FADD_VL", SDT_RISCVFPBinOp_VL, [SDNPCommutative]>;
124
139
def riscv_fsub_vl : SDNode<"RISCVISD::FSUB_VL", SDT_RISCVFPBinOp_VL>;
125
140
def riscv_fmul_vl : SDNode<"RISCVISD::FMUL_VL", SDT_RISCVFPBinOp_VL, [SDNPCommutative]>;
@@ -635,6 +650,34 @@ class VPatBinaryVL_V<SDPatternOperator vop,
635
650
op2_reg_class:$rs2,
636
651
(mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
637
652
653
+ multiclass VPatBinaryRM_VL_V<SDNode vop,
654
+ string instruction_name,
655
+ string suffix,
656
+ ValueType result_type,
657
+ ValueType op1_type,
658
+ ValueType op2_type,
659
+ ValueType mask_type,
660
+ int sew,
661
+ LMULInfo vlmul,
662
+ VReg result_reg_class,
663
+ VReg op1_reg_class,
664
+ VReg op2_reg_class> {
665
+ def : Pat<(result_type (vop
666
+ (op1_type op1_reg_class:$rs1),
667
+ (op2_type op2_reg_class:$rs2),
668
+ (result_type result_reg_class:$merge),
669
+ (mask_type V0),
670
+ (XLenVT timm:$roundmode),
671
+ VLOpFrag)),
672
+ (!cast<Instruction>(instruction_name#"_"#suffix#"_"# vlmul.MX#"_MASK")
673
+ result_reg_class:$merge,
674
+ op1_reg_class:$rs1,
675
+ op2_reg_class:$rs2,
676
+ (mask_type V0),
677
+ (XLenVT timm:$roundmode),
678
+ GPR:$vl, sew, TAIL_AGNOSTIC)>;
679
+ }
680
+
638
681
class VPatBinaryVL_V_RM<SDPatternOperator vop,
639
682
string instruction_name,
640
683
string suffix,
@@ -795,6 +838,35 @@ class VPatBinaryVL_XI<SDPatternOperator vop,
795
838
xop_kind:$rs2,
796
839
(mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
797
840
841
+ multiclass VPatBinaryRM_VL_XI<SDNode vop,
842
+ string instruction_name,
843
+ string suffix,
844
+ ValueType result_type,
845
+ ValueType vop1_type,
846
+ ValueType vop2_type,
847
+ ValueType mask_type,
848
+ int sew,
849
+ LMULInfo vlmul,
850
+ VReg result_reg_class,
851
+ VReg vop_reg_class,
852
+ ComplexPattern SplatPatKind,
853
+ DAGOperand xop_kind> {
854
+ def : Pat<(result_type (vop
855
+ (vop1_type vop_reg_class:$rs1),
856
+ (vop2_type (SplatPatKind (XLenVT xop_kind:$rs2))),
857
+ (result_type result_reg_class:$merge),
858
+ (mask_type V0),
859
+ (XLenVT timm:$roundmode),
860
+ VLOpFrag)),
861
+ (!cast<Instruction>(instruction_name#_#suffix#_# vlmul.MX#"_MASK")
862
+ result_reg_class:$merge,
863
+ vop_reg_class:$rs1,
864
+ xop_kind:$rs2,
865
+ (mask_type V0),
866
+ (XLenVT timm:$roundmode),
867
+ GPR:$vl, sew, TAIL_AGNOSTIC)>;
868
+ }
869
+
798
870
multiclass VPatBinaryVL_VV_VX<SDPatternOperator vop, string instruction_name,
799
871
list<VTypeInfo> vtilist = AllIntegerVectors,
800
872
bit isSEWAware = 0> {
@@ -893,6 +965,24 @@ multiclass VPatBinaryNVL_WV_WX_WI<SDPatternOperator vop, string instruction_name
893
965
}
894
966
}
895
967
968
+ multiclass VPatBinaryRM_NVL_WV_WX_WI<SDNode vop, string instruction_name> {
969
+ foreach VtiToWti = AllWidenableIntVectors in {
970
+ defvar vti = VtiToWti.Vti;
971
+ defvar wti = VtiToWti.Wti;
972
+ defm : VPatBinaryRM_VL_V<vop, instruction_name, "WV",
973
+ vti.Vector, wti.Vector, vti.Vector, vti.Mask,
974
+ vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass, vti.RegClass>;
975
+ defm : VPatBinaryRM_VL_XI<vop, instruction_name, "WX",
976
+ vti.Vector, wti.Vector, vti.Vector, vti.Mask,
977
+ vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass, SplatPat, GPR>;
978
+ defm : VPatBinaryRM_VL_XI<vop, instruction_name, "WI",
979
+ vti.Vector, wti.Vector, vti.Vector, vti.Mask,
980
+ vti.Log2SEW, vti.LMul, vti.RegClass, wti.RegClass,
981
+ !cast<ComplexPattern>(SplatPat#_#uimm5),
982
+ uimm5>;
983
+ }
984
+ }
985
+
896
986
class VPatBinaryVL_VF<SDPatternOperator vop,
897
987
string instruction_name,
898
988
ValueType result_type,
@@ -2376,6 +2466,10 @@ defm : VPatAVGADDVL_VV_VX_RM<riscv_avgflooru_vl, 0b10, suffix="U">;
2376
2466
defm : VPatAVGADDVL_VV_VX_RM<riscv_avgceils_vl, 0b00>;
2377
2467
defm : VPatAVGADDVL_VV_VX_RM<riscv_avgceilu_vl, 0b00, suffix="U">;
2378
2468
2469
+ // 12.5. Vector Narrowing Fixed-Point Clip Instructions
2470
+ defm : VPatBinaryRM_NVL_WV_WX_WI<riscv_vnclip_vl, "PseudoVNCLIP">;
2471
+ defm : VPatBinaryRM_NVL_WV_WX_WI<riscv_vnclipu_vl, "PseudoVNCLIPU">;
2472
+
2379
2473
// 12.5. Vector Narrowing Fixed-Point Clip Instructions
2380
2474
multiclass VPatTruncSatClipVL<VTypeInfo vti, VTypeInfo wti> {
2381
2475
defvar sew = vti.SEW;
@@ -2410,16 +2504,6 @@ multiclass VPatTruncSatClipVL<VTypeInfo vti, VTypeInfo wti> {
2410
2504
(!cast<Instruction>("PseudoVNCLIP_WI_"#vti.LMul.MX#"_MASK")
2411
2505
(vti.Vector (IMPLICIT_DEF)), wti.RegClass:$rs1, 0,
2412
2506
(vti.Mask V0), 0, GPR:$vl, vti.Log2SEW, TA_MA)>;
2413
-
2414
- def : Pat<(vti.Vector (riscv_trunc_vector_vl
2415
- (wti.Vector (riscv_umin_vl
2416
- (wti.Vector wti.RegClass:$rs1),
2417
- (wti.Vector (riscv_vmv_v_x_vl (wti.Vector undef), uminval, (XLenVT srcvalue))),
2418
- (wti.Vector undef), (wti.Mask V0), VLOpFrag)),
2419
- (vti.Mask V0), VLOpFrag)),
2420
- (!cast<Instruction>("PseudoVNCLIPU_WI_"#vti.LMul.MX#"_MASK")
2421
- (vti.Vector (IMPLICIT_DEF)), wti.RegClass:$rs1, 0,
2422
- (vti.Mask V0), 0, GPR:$vl, vti.Log2SEW, TA_MA)>;
2423
2507
}
2424
2508
}
2425
2509
0 commit comments