[libclc] [libclc] Produce subnormal results for exp/exp2 on FP32 (PR #212696)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 19:58:51 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 cl,inc -- libclc/clc/lib/generic/math/clc_exp.cl libclc/clc/lib/generic/math/clc_exp.inc libclc/clc/lib/generic/math/clc_exp2.cl libclc/clc/lib/generic/math/clc_exp2.inc --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/libclc/clc/lib/generic/math/clc_exp.inc b/libclc/clc/lib/generic/math/clc_exp.inc
index 249a23920..5539d6b68 100644
--- a/libclc/clc/lib/generic/math/clc_exp.inc
+++ b/libclc/clc/lib/generic/math/clc_exp.inc
@@ -45,7 +45,8 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp(__CLC_GENTYPE x) {
   // above is out of range, and an ill-formed exponent would make ldexp return
   // NaN. Any such input over/underflows and is saturated to inf/zero by the
   // ulim/llim selects below, so the clamp never affects a representable result.
-  __CLC_GENTYPE r = __clc_ldexp(y, __clc_clamp(p, (__CLC_INTN)-151, (__CLC_INTN)129));
+  __CLC_GENTYPE r =
+      __clc_ldexp(y, __clc_clamp(p, (__CLC_INTN)-151, (__CLC_INTN)129));
 
   // ln(largest_normal) = 88.72283905206835305366
   const __CLC_GENTYPE ulim = 0x1.62e430p+6f;
diff --git a/libclc/clc/lib/generic/math/clc_exp2.inc b/libclc/clc/lib/generic/math/clc_exp2.inc
index 8678b7510..12939a4f1 100644
--- a/libclc/clc/lib/generic/math/clc_exp2.inc
+++ b/libclc/clc/lib/generic/math/clc_exp2.inc
@@ -44,7 +44,8 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_exp2(__CLC_GENTYPE x) {
   // above is out of range, and an ill-formed exponent would make ldexp return
   // NaN. Any such input over/underflows and is saturated to inf/zero by the
   // ulim/llim selects below, so the clamp never affects a representable result.
-  __CLC_GENTYPE r = __clc_ldexp(y, __clc_clamp(p, (__CLC_INTN)-151, (__CLC_INTN)129));
+  __CLC_GENTYPE r =
+      __clc_ldexp(y, __clc_clamp(p, (__CLC_INTN)-151, (__CLC_INTN)129));
 
   const __CLC_GENTYPE ulim = 128.0f;
   // Smallest subnormal is 2^-149; below this the result underflows to zero.

``````````

</details>


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


More information about the cfe-commits mailing list