GCC's -ffast-math behavior

Miles Bader miles@gnu.org
Fri Feb 10 06:41:00 GMT 2012


xunxun <xunxun1982@gmail.com> writes:
>> If you switch to using SSE floating-point, e.g. using "-mfpmath=sse",
>> it will still call the library functions even when using -ffast-math
>> (because the SSE unit doesn't have special instructions like "fsin" or
>> "f2xm1").  I think SSE FP is typically faster than the 387 for many
>> CPUs anyway.
>>
> Well, that's right.
> But in my experience, -mfpmath=sse will slow my code very much.

Hmm, I've always found SSE FP to be a speedup -- sometimes a _big_
speedup -- over 387 FP, at least when one is using mostly primitive FP
operations (mul, divide, sqrt, etc) ... I think it's worth testing, at
least.

Complicated FP functions like sin, exp, etc, seem to be a little
faster on using 387 FP than using SSE FP -- but that's presumably
because when using SSE, those functions are implemented in -lm instead
of using special instructions.  Since you want to switch to a faster
FP library _anyway_, the quality of the standard FP library presumably
isn't much of a limitation for you... :]

> I think -mfpmath=sse option has some bugs on X86.

The x86 is really the only place that option is useful, so I hope it's
mostly OK there... :]

-Miles

-- 
Circus, n. A place where horses, ponies and elephants are permitted to see
men, women and children acting the fool.



More information about the Gcc-help mailing list