Re: Please revert b2e843161d
Steve Kargl <[email protected]> Fri, 26 Jun 2026 10:19:34 -0700
| Newsgroups | gmane.os.freebsd.devel.hackers |
|---|---|
| Message-ID | <[email protected]> |
On 6/26/26 09:17, Andrew Turner wrote: > > >> On 25 Jun 2026, at 19:32, Steve Kargl <[email protected]> wrote: >> >> On 6/25/26 10:57, Andrew Turner wrote: >>> I don’t expect it to work on amd64 in the general case. Godbolt shows both GCC and Clang generating an infinite loop jumping to its self [1]. It may work on some architecture levels, however I don’t know enough about amd64 to know if it’s safe to enable. >>> The USE_BUILTIN_* flags aren’t intended on being set by users as you found. >> >> The comment in the source code certainly does not alert a >> user to not use -DUSE_BUILTIN_FMAF (or any of the other >> USE_BUILTIN_*). > >> >> Architecture specific code should be in msun/arm/. It would >> also seem to me that if this is indeed arm specific then >> it should be guarded with "#if defined(__ARM) && …” > > Other architectures could use this if they have a simple instruction sequence that the compiler uses. I know about arm64 so am comfortable enabling it there, but not on other architectures I don’t use. > > Andrew My point is that a compiler will use its builtin if one is available in lieu of a function in libm. One does not need to pollute the msun source code with "#ifdef __builtin_XXX() #else ... #endif". It simply clutters comparisons to the libm code in NetBSD, OpenBSD, and Openlibm. I do recognize that one may need to specify a compiler option such as -mfma for gcc on amd64 to get a builtin. That is due to the lack of an fma instruction in the original amd64 instruction set. Can you at least add a cautionary comment in the source code that USE_BUILTIN_FMA[F] have only been tested on arm64 and may lead to segfaults on other architectures? -- steve