@@ -26,6 +26,7 @@ def SDT_LoongArchV1RUimm: SDTypeProfile<1, 2, [SDTCisVec<0>,
2626def SDT_LoongArchVreplgr2vr : SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisVec<0>, SDTCisInt<1>]>;
2727def SDT_LoongArchVFRECIPE : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVec<0>, SDTCisSameAs<0, 1>]>;
2828def SDT_LoongArchVFRSQRTE : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVec<0>, SDTCisSameAs<0, 1>]>;
29+ def SDT_LoongArchVLDREPL : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisPtrTy<1>]>;
2930
3031// Target nodes.
3132def loongarch_vreplve : SDNode<"LoongArchISD::VREPLVE", SDT_LoongArchVreplve>;
@@ -64,6 +65,10 @@ def loongarch_vsrli : SDNode<"LoongArchISD::VSRLI", SDT_LoongArchV1RUimm>;
6465def loongarch_vbsll : SDNode<"LoongArchISD::VBSLL", SDT_LoongArchV1RUimm>;
6566def loongarch_vbsrl : SDNode<"LoongArchISD::VBSRL", SDT_LoongArchV1RUimm>;
6667
68+ def loongarch_vldrepl
69+ : SDNode<"LoongArchISD::VLDREPL",
70+ SDT_LoongArchVLDREPL, [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
71+
6772def immZExt1 : ImmLeaf<i64, [{return isUInt<1>(Imm);}]>;
6873def immZExt2 : ImmLeaf<i64, [{return isUInt<2>(Imm);}]>;
6974def immZExt3 : ImmLeaf<i64, [{return isUInt<3>(Imm);}]>;
@@ -1433,6 +1438,14 @@ multiclass PatCCVrVrF<CondCode CC, string Inst> {
14331438 (!cast<LAInst>(Inst#"_D") LSX128:$vj, LSX128:$vk)>;
14341439}
14351440
1441+ multiclass VldreplPat<ValueType vt, LAInst Inst, Operand ImmOpnd> {
1442+ def : Pat<(vt(loongarch_vldrepl BaseAddr:$rj)), (Inst BaseAddr:$rj, 0)>;
1443+ def : Pat<(vt(loongarch_vldrepl(AddrConstant GPR:$rj, ImmOpnd:$imm))),
1444+ (Inst GPR:$rj, ImmOpnd:$imm)>;
1445+ def : Pat<(vt(loongarch_vldrepl(AddLike BaseAddr:$rj, ImmOpnd:$imm))),
1446+ (Inst BaseAddr:$rj, ImmOpnd:$imm)>;
1447+ }
1448+
14361449let Predicates = [HasExtLSX] in {
14371450
14381451// VADD_{B/H/W/D}
@@ -2342,6 +2355,7 @@ def : Pat<(int_loongarch_lsx_vld GPR:$rj, timm:$imm),
23422355def : Pat<(int_loongarch_lsx_vldx GPR:$rj, GPR:$rk),
23432356 (VLDX GPR:$rj, GPR:$rk)>;
23442357
2358+ // vldrepl
23452359def : Pat<(int_loongarch_lsx_vldrepl_b GPR:$rj, timm:$imm),
23462360 (VLDREPL_B GPR:$rj, (to_valid_timm timm:$imm))>;
23472361def : Pat<(int_loongarch_lsx_vldrepl_h GPR:$rj, timm:$imm),
@@ -2351,6 +2365,11 @@ def : Pat<(int_loongarch_lsx_vldrepl_w GPR:$rj, timm:$imm),
23512365def : Pat<(int_loongarch_lsx_vldrepl_d GPR:$rj, timm:$imm),
23522366 (VLDREPL_D GPR:$rj, (to_valid_timm timm:$imm))>;
23532367
2368+ defm : VldreplPat<v16i8, VLDREPL_B, simm12_addlike>;
2369+ defm : VldreplPat<v8i16, VLDREPL_H, simm11_lsl1>;
2370+ defm : VldreplPat<v4i32, VLDREPL_W, simm10_lsl2>;
2371+ defm : VldreplPat<v2i64, VLDREPL_D, simm9_lsl3>;
2372+
23542373// store
23552374def : Pat<(int_loongarch_lsx_vst LSX128:$vd, GPR:$rj, timm:$imm),
23562375 (VST LSX128:$vd, GPR:$rj, (to_valid_timm timm:$imm))>;
0 commit comments