[llvm] [AMDGPU] Use 1-iteration Newton-Raphson refinement for FP32 reciprocal. (PR #194716)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 13:58:26 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
index 201294310..985f09090 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
@@ -924,11 +924,11 @@ bool AMDGPUCodeGenPrepareImpl::expandReciprocalNewtonRaphson(
     Value *Scale = nullptr;
     if (!HasFP32DenormalFlush) {
       Value *AbsD = B.CreateUnaryIntrinsic(Intrinsic::fabs, D);
-      Value *IsLarge = B.CreateFCmpOGT(
-          AbsD, ConstantFP::get(Ty, MaxNormalWithNormalRcp));
-      Scale = B.CreateSelect(
-          IsLarge, ConstantFP::get(Ty, LargeNormalScaleFactor),
-          ConstantFP::get(Ty, 1.0));
+      Value *IsLarge =
+          B.CreateFCmpOGT(AbsD, ConstantFP::get(Ty, MaxNormalWithNormalRcp));
+      Scale =
+          B.CreateSelect(IsLarge, ConstantFP::get(Ty, LargeNormalScaleFactor),
+                         ConstantFP::get(Ty, 1.0));
       DForRcp = B.CreateFMul(D, Scale);
     }
     Value *Y0 = B.CreateUnaryIntrinsic(Intrinsic::amdgcn_rcp, DForRcp);

``````````

</details>


https://github.com/llvm/llvm-project/pull/194716


More information about the llvm-commits mailing list