[clang] [llvm] [LoongArch] [CodeGen] Add options for Clang to generate LoongArch-specific frecipe & frsqrte instructions (PR #109917)
Lu Weining via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 10 20:22:10 PDT 2024
================
@@ -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) {
----------------
SixWeining wrote:
Useless `{}`.
https://github.com/llvm/llvm-project/pull/109917
More information about the cfe-commits
mailing list