Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Dec 2007 21:40:34 -0800
From:      "Carl Shapiro" <carl.shapiro@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   critical floating point incompatibility
Message-ID:  <4dcb5abd0712192140w29fd39fh53b09fdd4d20e880@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Developers,

There is a critical incompatibility between the floating point
environment of the 32-bit compatibility environment of AMD64 systems
and a genuine i386 system.

The default setting of the x87 floating point control word on the i386
port is 0x127F.  Among other things, this value sets the precision
control to double precision.  The default setting of the x87 floating
point control word on the AMD64 is 0x37F.  This value sets the
precision control to double-extended precision.  Since the AMD64 port
uses SSE2 instructions for single and double precision arithmetic
(thereby reserving the x87 for double-extended precision) this is a
reasonable setting.  Unfortunately, when a 32-bit binary is run under
compatibility on an AMD64 system, the floating point control word is
0x37F, not 0x127F. 32-bit binaries do not expect the floating point
environment to be in this state.  The net effect is that all but the
most trivial programs using x87 floating point arithmetic instructions
will produce different values when run on a native i386 system than
when run under compatibility on a 64-bit system!

It seems clear that the right thing to do is to set the floating point
environment to the i386 default for i386 binaries.  Is the current
behavior intended?

Carl



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4dcb5abd0712192140w29fd39fh53b09fdd4d20e880>