Makefile: no fused multiply-add (-ffp-contract=off) (#2142)

GCC and clang fuse a*b+c into one FMA instruction where the CPU has one
(AArch64, ARMv7 VFPv4, PowerPC): rounded once instead of twice, so the
floating point results differ from x86, where there is no FMA in the
baseline instruction set. With the flag every host computes the same
values: netplay between x86 and ARM, save states and RunAhead.

x86 and x86-64: the generated code is the same with and without the flag.


Claude-Session: https://claude.ai/code/session_01N3fzdsnzkQVtgYtYzqepjX

Co-authored-by: Claude <[email protected]>
This commit is contained in:
zanacandClaude authored and GitHub committed 2026-10-25 03:25:40 -04:00
1 parent d57fdfe4ee
commit cc7b0dd9a1
1 file changed
+8
+8
View File
@@ -828,6 +828,14 @@ ifeq (,$(findstring msvc,$(platform)))
CFLAGS += -Werror=vla -Werror=declaration-after-statement
endif
# no fused multiply-add: a*b+c rounded once (FMA) on AArch64, ARMv7 VFPv4
# and PowerPC gives other results than x86, where it is rounded twice;
# with it off the floating point results are the same on every host
# (netplay between them, save states and RunAhead)
ifeq (,$(findstring msvc,$(platform)))
CFLAGS += -ffp-contract=off
endif
# Required for RZIP support in cheat.c
CFLAGS += -DHAVE_ZLIB