================ @@ -5902,6 +5914,92 @@ Register LoongArchTargetLowering::getExceptionSelectorRegister( return LoongArch::R5; } +//===----------------------------------------------------------------------===// +// Target Optimization Hooks +//===----------------------------------------------------------------------===// + +static int getEstimateRefinementSteps(EVT VT, + const LoongArchSubtarget &Subtarget) { + // Feature FRECIPE instrucions relative accuracy is 2^-14. + // IEEE float has 23 digits and double has 52 digits. + int RefinementSteps = VT.getScalarType() == MVT::f64 ? 2 : 1; + return RefinementSteps; +} + +SDValue LoongArchTargetLowering::getSqrtEstimate(SDValue Operand, + SelectionDAG &DAG, int Enabled, + int &RefinementSteps, + bool &UseOneConstNR, + bool Reciprocal) const { + if (Subtarget.hasFrecipe()) { + SDLoc DL(Operand); + EVT VT = Operand.getValueType(); + unsigned Opcode; + + if (VT == MVT::f32) { + Opcode = LoongArchISD::FRSQRTE_S; + } else if (VT == MVT::f64 && Subtarget.hasBasicD()) { + Opcode = LoongArchISD::FRSQRTE_D; + } else if (VT == MVT::v4f32 && Subtarget.hasExtLSX()) { + Opcode = LoongArchISD::VFRSQRTE_S; + } else if (VT == MVT::v2f64 && Subtarget.hasExtLSX()) { + Opcode = LoongArchISD::VFRSQRTE_D; + } else if (VT == MVT::v8f32 && Subtarget.hasExtLASX()) { + Opcode = LoongArchISD::XVFRSQRTE_S; + } else if (VT == MVT::v4f64 && Subtarget.hasExtLASX()) { + Opcode = LoongArchISD::XVFRSQRTE_D; + } else { + return SDValue(); + } + + UseOneConstNR = false; + if (RefinementSteps == ReciprocalEstimate::Unspecified) + RefinementSteps = getEstimateRefinementSteps(VT, Subtarget); + + SDValue Estimate = DAG.getNode(Opcode, DL, VT, Operand); + if (Reciprocal) { ---------------- SixWeining wrote:
Useless `{}`. https://github.com/llvm/llvm-project/pull/109917 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits