glibc/bits
Kito Cheng a225cb3ee9
Remap __GLIBC_FLT_EVAL_METHOD to 0 if __FLT_EVAL_METHOD__ is -1
__GLIBC_FLT_EVAL_METHOD will effect the definition of float_t and
double_t, currently we'll set __GLIBC_FLT_EVAL_METHOD to 2 when
__FLT_EVAL_METHOD__ is -1, that means we'll define float_t and double_t
to long double.

However some target isn't natively (HW) support long double like AArch64 and
RISC-V, they defined long double as 128-bits IEEE 754 floating point type.

That means setting __GLIBC_FLT_EVAL_METHOD to 2 will cause very inefficient
code gen for those target who didn't provide native support for long
double, and that's violate the spirit float_t and double_t - most efficient
types at least as wide as float and double.

So this patch propose to remap __GLIBC_FLT_EVAL_METHOD to 0 rather than
2 when __FLT_EVAL_METHOD__ is -1, which means we'll use float/double
rather than long double for float_t and double_t.

Note: __FLT_EVAL_METHOD__ == -1 means the precision is indeterminable,
      which means compiler might using indeterminable precision during
      optimization/code gen, clang will set this value to -1 when fast
      math is enabled.

Note: Default definition float_t and double_t in current glibc:
      |  __GLIBC_FLT_EVAL_METHOD | float_t     | double_t
      |               0 or 16    | float       | double
      |               1          | double      | doulbe
      |               2          | long double | long double
      More complete list see math/math.h

Note: RISC-V has defined ISA extension to support 128-bits IEEE 754
      floating point operations, but only rare RISC-V core will implement that.

Related link:

[1] LLVM issue (__FLT_EVAL_METHOD__ is set to -1 with Ofast. #60781):
    https://github.com/llvm/llvm-project/issues/60781
[2] Last version of this patch: https://sourceware.org/pipermail/libc-alpha/2023-February/145622.html

Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
Link: https://inbox.sourceware.org/libc-alpha/20230314151948.12892-1-kito.cheng@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2023-04-28 07:02:48 -07:00
..
types Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
atomic_wide_counter.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
byteswap.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
confname.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dirent_ext.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dirent.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl_find_object.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dlfcn.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
elfclass.h Update. 1999-07-27 05:53:25 +00:00
endian.h
environments.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
errno.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
fcntl.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
fenv.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
floatn-common.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
floatn.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
flt-eval-method.h Remap __GLIBC_FLT_EVAL_METHOD to 0 if __FLT_EVAL_METHOD__ is -1 2023-04-28 07:02:48 -07:00
fp-fast.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
fp-logb.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
hwcap.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
in.h [hurd] Add MTU_DISCOVER values 2023-02-15 15:14:06 +01:00
indirect-return.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ioctl-types.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ioctls.h
ipc.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ipctypes.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
iscanonical.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
libc-header-start.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
libm-simd-decl-stubs.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
link_lavcurrent.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
link.h * csu/elf-init.c (__libc_csu_fini): Don't do anything here. 2005-01-06 22:40:27 +00:00
local_lim.h
long-double.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
math-vector.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
mathdef.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
mman_ext.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
mman.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
mqueue.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
msq.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
netdb.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
param.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
poll.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
posix_opt.h
pthreadtypes.h 2002-11-10 Roland McGrath <roland@redhat.com> 2002-11-10 23:22:35 +00:00
resource.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sched.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
select.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sem.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
setjmp.h
shm.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sigaction.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sigcontext.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sigevent-consts.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
siginfo-consts.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
signal_ext.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
signum-arch.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
signum-generic.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sigstack.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sigstksz.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sigthread.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sockaddr.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
socket.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ss_flags.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
stat.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
statfs.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
statvfs.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
stdint-intn.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
stdint-uintn.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
stdlib-bsearch.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
syslog-path.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sysmacros.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
termios.h hurd: Fix tcflag_t and speed_t types on 64-bit 2023-02-12 20:03:18 +01:00
time64.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
time.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
timesize.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
typesizes.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
uintn-identity.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
uio_lim.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
uio-ext.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
unistd_ext.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
utmp.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
utsname.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
waitflags.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
waitstatus.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wchar.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wordsize.h Define wordsize.h macros everywhere 2016-11-04 09:37:44 -07:00