x86: Fix x86_64 build failure with -Os (BZ 33367)

The 13cfd77bf5 change broke the b5d88fa6c3 fix by removing the symbol
to __symbol redirections.  Although it works for -O2 with both gcc
and clang, with -Os without the redirection, the libcall might still
be issued.

This patch reinstates the b5d88fa6c3 fix, with a modification that
allows each ifunc variant to control which trunc to issue.  This is
required for clang, which defines HAVE_X86_INLINE_TRUNC to 1 (meaning
that trunc will always be lowered to the instruction on -Os).

Checked on x86_64-linux-gnu with -O2 and -Os with gcc-15 and clang-18.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Adhemerval Zanella 2025-12-23 14:30:45 -03:00
parent 8efe2b03db
commit 422c3a5baf
6 changed files with 12 additions and 2 deletions

View File

@ -25,12 +25,15 @@ __modf (double x, double *iptr)
{
uint64_t t = asuint64 (x);
#if USE_TRUNC_BUILTIN
# ifndef TRUNC
# define TRUNC trunc
# endif
if (is_inf (t))
{
*iptr = x;
return copysign (0.0, x);
}
*iptr = trunc (x);
*iptr = TRUNC (x);
return copysign (x - *iptr, x);
#else
int e = get_exponent (t);

View File

@ -25,12 +25,15 @@ __modff (float x, float *iptr)
{
uint32_t t = asuint (x);
#if USE_TRUNCF_BUILTIN
# ifndef TRUNCF
# define TRUNCF truncf
# endif
if (is_inf (t))
{
*iptr = x;
return copysignf (0.0, x);
}
*iptr = truncf (x);
*iptr = TRUNCF (x);
return copysignf (x - *iptr, x);
#else
int e = get_exponent (t);

View File

@ -1,2 +1,3 @@
#define __modf __modf_avx
#define TRUNC __trunc
#include <sysdeps/ieee754/dbl-64/s_modf.c>

View File

@ -1,2 +1,3 @@
#define __modf __modf_sse41
#define TRUNC __trunc
#include <sysdeps/ieee754/dbl-64/s_modf.c>

View File

@ -1,2 +1,3 @@
#define __modff __modff_avx
#define TRUNCF __truncf
#include <sysdeps/ieee754/flt-32/s_modff.c>

View File

@ -1,2 +1,3 @@
#define __modff __modff_sse41
#define TRUNCF __truncf
#include <sysdeps/ieee754/flt-32/s_modff.c>