mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-06 08:23:19 +08:00
Fuse multiply-adds in the Math port on macOS arm64, as Node's build does
Node for macOS on arm64 is compiled by clang, which contracts a multiply and an add within one expression into a fused multiply-add. Its sin, cos, tan, asin, acos, atan, sinh, asinh, acosh, atanh, exp, expm1, log, log1p and log10 differ from the unfused results in the last bit for some inputs, so corpus 7717 and 7718 failed on macOS. scr_ieee754.c now sets FP_CONTRACT ON for Apple arm64 targets. Other targets keep it off and compile to the same code as before.
This commit is contained in:
@@ -32,9 +32,16 @@
|
||||
|
||||
#include "scr_ieee754.h"
|
||||
|
||||
/* Each operation rounds on its own, as in V8's build: no fused
|
||||
* multiply-add, which would change the results on targets that have one. */
|
||||
/* Floating-point contraction follows Node's build of this file. Node for
|
||||
* macOS on arm64 is compiled by clang, which fuses a multiply and an add
|
||||
* within one expression into a fused multiply-add; the results differ from
|
||||
* the unfused ones in the last bit for some inputs. Other builds round each
|
||||
* operation on its own, as Node's x86-64 builds do. */
|
||||
#if defined(__APPLE__) && defined(__aarch64__)
|
||||
#pragma STDC FP_CONTRACT ON
|
||||
#else
|
||||
#pragma STDC FP_CONTRACT OFF
|
||||
#endif
|
||||
|
||||
static inline uint64_t scr_fd_bits(double d) {
|
||||
uint64_t bits;
|
||||
|
||||
Reference in New Issue
Block a user