This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: -mfpmath=387 flag does not prevent gcc from using SSE/SSE2 instructions
> From the x86-64 ABI, I notice that most FP code would be translated to
> SSE/SSE2 instructions using the SSE registers. Only long double data types
> (80 bits) have to use the 387, and SSE/SSE2 is the forced way for all other
> floating point types.
> (ref: http://www.x86-64.org/lists/discuss/msg01021.html)
> This makes sense.
>
> There may be some efficiency issues in using mixed 387/SSE code, as moving
> data between register sets seems extremely slow. If there is code that
> executes faster when compiled for 387, perhaps this should be restricted to
Yes, there are several situations, where 387 is faster than SSE.
For instance SSE lack direct support for conditional moves, neg, abs,
sin, cos, some converisons are more effective in 387 and there are the
reversed operand order alternatives sometimes saving need for explicit
reg-reg moves.
I hope that once GCC will be able to decide in between the register
classes and put code that fits for 387 instructions to 387 and vice
versa. This is not done currently very well but that what -mfpmath
would allow.
> 32-bit mode software?
>
> So, perhaps -mfpmath=387 should be deprecated for x86_64?
>
> What happens if I specify -mfpmath=sse and try to use long doubles?
They will be done in 387. -mfpmath=sse says "you must do
computations according to the IEEE standard" while -mfpmath=387 "you
must use 80bit temporaries to keep legacy code happy", while
-mfpmath=387,sse says "do whatever you want".
GCC will cheat and use both instruction sets when appropriate under the
rules above.
Still GCC will use SSE scalar flating point when available (via
-march=k8/pentium4 switch) in -mfpmath=387 when it knows it won't change
the behaviour and 387 in -mfpmath=sse when there is no way to do it in
SSE or it knows that it won't make difference to do it in 387.
This has nothing to do with the argument passing conventions except for
that fact that the 386 argument passing is bad for -mfpmath=sse and
AMD64 argument passing is bad for -mfpmath=387.
Perhaps documentation needs to be clarified here...
There are switches -mnosse -mno387 that do what you expect from
-mfpmath. In -mno387 an external library will be called for long double
operations and for -nosse really no SSE code will appear (and compiler
will complain when you call floating point function in AMD64 ABI)
Honza
>
> Thanks,
> --
> André Derrick Balsa (Andrew)
> andrebalsa@mailingaddress.org