@@ -95,6 +95,29 @@ def vsplati64_imm_eq_63 : PatFrags<(ops), [(build_vector),
9595 Imm.getBitWidth() == EltTy.getSizeInBits() && Imm == 63;
9696}]>;
9797
98+ def vsplatf32_fpimm_eq_1
99+ : PatFrags<(ops), [(bitconvert (v4i32 (build_vector))),
100+ (bitconvert (v8i32 (build_vector)))], [{
101+ APInt Imm;
102+ EVT EltTy = N->getValueType(0).getVectorElementType();
103+ N = N->getOperand(0).getNode();
104+
105+ return selectVSplat(N, Imm, EltTy.getSizeInBits()) &&
106+ Imm.getBitWidth() == EltTy.getSizeInBits() &&
107+ Imm == APFloat(+1.0f).bitcastToAPInt();
108+ }]>;
109+ def vsplatf64_fpimm_eq_1
110+ : PatFrags<(ops), [(bitconvert (v2i64 (build_vector))),
111+ (bitconvert (v4i64 (build_vector)))], [{
112+ APInt Imm;
113+ EVT EltTy = N->getValueType(0).getVectorElementType();
114+ N = N->getOperand(0).getNode();
115+
116+ return selectVSplat(N, Imm, EltTy.getSizeInBits()) &&
117+ Imm.getBitWidth() == EltTy.getSizeInBits() &&
118+ Imm == APFloat(+1.0).bitcastToAPInt();
119+ }]>;
120+
98121def vsplati8imm7 : PatFrag<(ops node:$reg),
99122 (and node:$reg, vsplati8_imm_eq_7)>;
100123def vsplati16imm15 : PatFrag<(ops node:$reg),
@@ -1173,6 +1196,13 @@ multiclass PatVr<SDPatternOperator OpNode, string Inst> {
11731196 (!cast<LAInst>(Inst#"_D") LSX128:$vj)>;
11741197}
11751198
1199+ multiclass PatVrF<SDPatternOperator OpNode, string Inst> {
1200+ def : Pat<(v4f32 (OpNode (v4f32 LSX128:$vj))),
1201+ (!cast<LAInst>(Inst#"_S") LSX128:$vj)>;
1202+ def : Pat<(v2f64 (OpNode (v2f64 LSX128:$vj))),
1203+ (!cast<LAInst>(Inst#"_D") LSX128:$vj)>;
1204+ }
1205+
11761206multiclass PatVrVr<SDPatternOperator OpNode, string Inst> {
11771207 def : Pat<(OpNode (v16i8 LSX128:$vj), (v16i8 LSX128:$vk)),
11781208 (!cast<LAInst>(Inst#"_B") LSX128:$vj, LSX128:$vk)>;
@@ -1525,6 +1555,21 @@ def : Pat<(fma v4f32:$vj, v4f32:$vk, v4f32:$va),
15251555def : Pat<(fma v2f64:$vj, v2f64:$vk, v2f64:$va),
15261556 (VFMADD_D v2f64:$vj, v2f64:$vk, v2f64:$va)>;
15271557
1558+ // VFSQRT_{S/D}
1559+ defm : PatVrF<fsqrt, "VFSQRT">;
1560+
1561+ // VFRECIP_{S/D}
1562+ def : Pat<(fdiv vsplatf32_fpimm_eq_1, v4f32:$vj),
1563+ (VFRECIP_S v4f32:$vj)>;
1564+ def : Pat<(fdiv vsplatf64_fpimm_eq_1, v2f64:$vj),
1565+ (VFRECIP_D v2f64:$vj)>;
1566+
1567+ // VFRSQRT_{S/D}
1568+ def : Pat<(fdiv vsplatf32_fpimm_eq_1, (fsqrt v4f32:$vj)),
1569+ (VFRSQRT_S v4f32:$vj)>;
1570+ def : Pat<(fdiv vsplatf64_fpimm_eq_1, (fsqrt v2f64:$vj)),
1571+ (VFRSQRT_D v2f64:$vj)>;
1572+
15281573// VSEQ[I]_{B/H/W/D}
15291574defm : PatCCVrSimm5<SETEQ, "VSEQI">;
15301575defm : PatCCVrVr<SETEQ, "VSEQ">;
0 commit comments