mirror of
git://sourceware.org/git/glibc.git
synced 2024-12-15 04:20:28 +08:00
a225cb3ee9
__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>
41 lines
1.5 KiB
C
41 lines
1.5 KiB
C
/* Define __GLIBC_FLT_EVAL_METHOD.
|
|
Copyright (C) 2016-2023 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef _MATH_H
|
|
# error "Never use <bits/flt-eval-method.h> directly; include <math.h> instead."
|
|
#endif
|
|
|
|
/* __GLIBC_FLT_EVAL_METHOD is the value of FLT_EVAL_METHOD used to
|
|
determine the evaluation method typedefs such as float_t and
|
|
double_t. It must be a value from C11 or TS 18661-3:2015, and not
|
|
-1. */
|
|
|
|
/* In the default version of this header, follow __FLT_EVAL_METHOD__.
|
|
If __FLT_EVAL_METHOD__ is not defined or set to -1, assume there is no
|
|
excess precision and use the value 0 (this is correct for most targets). */
|
|
|
|
#ifdef __FLT_EVAL_METHOD__
|
|
# if __FLT_EVAL_METHOD__ == -1
|
|
# define __GLIBC_FLT_EVAL_METHOD 0
|
|
# else
|
|
# define __GLIBC_FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
|
# endif
|
|
#else
|
|
# define __GLIBC_FLT_EVAL_METHOD 0
|
|
#endif
|