about summary refs log tree commit diff
path: root/math/s_clog10_template.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2021-12-31 09:50:50 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-01-10 14:27:17 +0000
commit347a5b592c91f0230d52a5117fd83e1f75028207 (patch)
treecef1eb7585b59b17118ad72f82856b39f94cfd14 /math/s_clog10_template.c
parente72ef23ee88187284b4b1ca9b2e314e618429d35 (diff)
downloadglibc-347a5b592c91f0230d52a5117fd83e1f75028207.tar.gz
glibc-347a5b592c91f0230d52a5117fd83e1f75028207.tar.xz
glibc-347a5b592c91f0230d52a5117fd83e1f75028207.zip
math: Fix float conversion regressions with gcc-12 [BZ #28713]
Converting double precision constants to float is now affected by the
runtime dynamic rounding mode instead of being evaluated at compile
time with default rounding mode (except static object initializers).

This can change the computed result and cause performance regression.
The known correctness issues (increased ulp errors) are already fixed,
this patch fixes remaining cases of unnecessary runtime conversions.

Add float M_* macros to math.h as new GNU extension API.  To avoid
conversions the new M_* macros are used and instead of casting double
literals to float, use float literals (only required if the conversion
is inexact).

The patch was tested on aarch64 where the following symbols had new
spurious conversion instructions that got fixed:

  __clog10f
  __gammaf_r_finite@GLIBC_2.17
  __j0f_finite@GLIBC_2.17
  __j1f_finite@GLIBC_2.17
  __jnf_finite@GLIBC_2.17
  __kernel_casinhf
  __lgamma_negf
  __log1pf
  __y0f_finite@GLIBC_2.17
  __y1f_finite@GLIBC_2.17
  cacosf
  cacoshf
  casinhf
  catanf
  catanhf
  clogf
  gammaf_positive

Fixes bug 28713.

Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Diffstat (limited to 'math/s_clog10_template.c')
-rw-r--r--math/s_clog10_template.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/math/s_clog10_template.c b/math/s_clog10_template.c
index f5a0873ad3..e50bd6ccf9 100644
--- a/math/s_clog10_template.c
+++ b/math/s_clog10_template.c
@@ -72,7 +72,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x)
       if (absx == 1 && scale == 0)
 	{
 	  __real__ result = (M_LOG1P (absy * absy)
-			     * ((FLOAT) M_MLIT (M_LOG10E) / 2));
+			     * (M_MLIT (M_LOG10E) / 2));
 	  math_check_force_underflow_nonneg (__real__ result);
 	}
       else if (absx > 1 && absx < 2 && absy < 1 && scale == 0)
@@ -80,7 +80,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x)
 	  FLOAT d2m1 = (absx - 1) * (absx + 1);
 	  if (absy >= M_EPSILON)
 	    d2m1 += absy * absy;
-	  __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2);
+	  __real__ result = M_LOG1P (d2m1) * (M_MLIT (M_LOG10E) / 2);
 	}
       else if (absx < 1
 	       && absx >= M_LIT (0.5)
@@ -88,7 +88,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x)
 	       && scale == 0)
 	{
 	  FLOAT d2m1 = (absx - 1) * (absx + 1);
-	  __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2);
+	  __real__ result = M_LOG1P (d2m1) * (M_MLIT (M_LOG10E) / 2);
 	}
       else if (absx < 1
 	       && absx >= M_LIT (0.5)
@@ -96,7 +96,7 @@ M_DECL_FUNC (__clog10) (CFLOAT x)
 	       && absx * absx + absy * absy >= M_LIT (0.5))
 	{
 	  FLOAT d2m1 = M_SUF (__x2y2m1) (absx, absy);
-	  __real__ result = M_LOG1P (d2m1) * ((FLOAT) M_MLIT (M_LOG10E) / 2);
+	  __real__ result = M_LOG1P (d2m1) * (M_MLIT (M_LOG10E) / 2);
 	}
       else
 	{