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>
{
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);
{
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);
#define __modf __modf_avx
+#define TRUNC __trunc
#include <sysdeps/ieee754/dbl-64/s_modf.c>
#define __modf __modf_sse41
+#define TRUNC __trunc
#include <sysdeps/ieee754/dbl-64/s_modf.c>
#define __modff __modff_avx
+#define TRUNCF __truncf
#include <sysdeps/ieee754/flt-32/s_modff.c>
#define __modff __modff_sse41
+#define TRUNCF __truncf
#include <sysdeps/ieee754/flt-32/s_modff.c>