This is the mail archive of the
mailing list for the GCC project.
Re: [BENCHMARK]-mfpmath=sse should disable x387 intrinsics
- From: Uros Bizjak <uros at kss-loka dot si>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Richard Guenther <richard dot guenther at gmail dot com>,gcc-patches at gcc dot gnu dot org
- Date: Fri, 26 Nov 2004 08:48:16 +0100
- Subject: Re: [BENCHMARK]-mfpmath=sse should disable x387 intrinsics
- References: <Pine.LNX.email@example.com>
Roger Sayle wrote:
I would like to present a small table of options for P4 and K8, attached
as text attachment to this message, to preserve formatting.
Finally, you may find that if you want to use "-mfpmath=sse" effectively,
it may help to build a libm multi-lib (either sse-specific or soft-float)
that maximizes performance. Again, most Linux distributions don't bother
with such a specialization as -fpmath=sse is so rarely a win.
I don't think its unreasonable for you to ask for this patch to be
reverted. An even better compromise is to only use this logic on
TARGET_64BIT where its a clear advantage by default. There's also
the complication that the *BSD support in the i386.c backend makes
it difficult to enable and disable 387 intrinsics independently.
Apparently, their kernel x87 emulator doesn't handle "fancy math",
so i386.c plays games with "-mfancy-math-387", such that
"-mno-fancy-math-387" no longer works on Pentium4, and the only way
to disable x87 intrinsics on the command-line it to use the corrected
I hope, that this table shows how various -mfpmath options should be
handled for P4 and K8.
The default libm library is with i387 instructions, and the default is
-mfpmath=i387. Unless a sse math library is present, there is no point
to disable i387 intrinsics, even when -mfpmath=sse is specified. I
suggest that -mfpmath=sse disables only "normal" i387 code (fmul,fadd,
etc...), but leaves generation of intrinsics on. These intrinsics are
disabled anyway without -ffast-math. -mno-fancy-math-387 should also
disable these instructions.
The default libm uses sse instructions, and the default is -mfpmath=sse.
Because (as Roger said) the default sse library is faster and more
accurate than i387 intrinsics, even -mfpmath=i387 should _not_ generate
i387 intrinsics, but should call sse math library. If someone wants to
use i387 intrinsics, -mfancy-math-i387 (together with -ffast-math)
should be specified.
In this case, -mno-fancy-math-387 does what it should - enables and
disables use of "fancy" i387 instructions indepenently of -mfpmath
choice. Actually, as it can be seen in attached table, the difference is
only in default value of "x86_arch_always_fancy_math_387" variable,
which should IMHO be cleared as a default choice for K8.
P4: -mfpmath=387 -mfpmath=sse -mfpmath=sse,i387 -mno-fancy-math-387
sse - x x ?
x87 x - x ?
x87intr x x x -
K8: -mfpmath=387 -mfpmath=sse -mfpmath=sse,i387 -mfancy-math-387
sse - x x ?
x87 x - x ?
x87intr - - - x