Skip to content

Commit

Permalink
Avoid the use of SSE instructions (R)SQRTSS for sqrtf and 1/sqrtf.
Browse files Browse the repository at this point in the history
When using the -ffast-math option, GCC uses SSE instructions SQRTSS for
sqrtf and RSQRTSS for 1/sqrtf. This results in a loss of precision
according to the GCC documentation: "the precision of the sequence can
be decreased by up to 2 ulp (i.e. the inverse of 1.0 equals
0.99999994)".
This loss of precision affects some games.
Fixes the broken AI in Soldiers of Fortune.
  • Loading branch information
flyinghead committed Jul 8, 2018
1 parent a89ff1e commit efa145f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions shell/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ifneq (,$(findstring x86,$(platform)))
MFLAGS += -m32
ASFLAGS += --32
LDFLAGS += -m32
CFLAGS += -m32 -D TARGET_LINUX_x86 -D TARGET_NO_AREC -fsingle-precision-constant
CFLAGS += -m32 -D TARGET_LINUX_x86 -D TARGET_NO_AREC -fsingle-precision-constant -fno-builtin-sqrtf
CXXFLAGS += -fno-exceptions

ifneq (,$(findstring sse4_1,$(platform)))
Expand All @@ -102,7 +102,7 @@ else ifneq (,$(findstring x64,$(platform)))
X64_REC := 1
NOT_ARM := 1
USE_X11 := 1
CFLAGS += -D TARGET_LINUX_x64 -D TARGET_NO_AREC -fsingle-precision-constant
CFLAGS += -D TARGET_LINUX_x64 -D TARGET_NO_AREC -fsingle-precision-constant -fno-builtin-sqrtf
CXXFLAGS += -fexceptions

ifneq (,$(findstring sse4_1,$(platform)))
Expand Down

0 comments on commit efa145f

Please sign in to comment.