[flang-commits] [flang] [llvm] [flang] Fix wrong result for exponentiation when denormal is expected (PR #205262)

via flang-commits flang-commits at lists.llvm.org
Mon Oct 12 01:17:19 PDT 2026


================
@@ -208,6 +208,10 @@ RT_API_ATTRS BTy FPowI(BTy base, ETy exp) {
   } else if (isNegativePower) {
     exp = -exp;
   }
+  if (isNegativePower && base != BTy{0} && ABSTy<BTy>::compute(base) > BTy{1}) {
----------------
ejose02 wrote:

Addressed in the latest commit. FPowI no longer uses ABSTy or any |base|>1 upfront reciprocal, so we avoid std::abs(__float128)
Also fixed the runtime accuracy regression from the earlier unconditional reciprocal: compute the direct negative power first and only retry from 1/base when 1/result underflows to zero (subnormal case). Ordinary cases like 3.0**(-2) and 7.0**(-5) stay on the direct path again.

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


More information about the flang-commits mailing list