------- Comment #6 from seongbae dot park at gmail dot com 2006-10-05 05:00
-------
For example:
# cat m.c
int todouble(double a, double b) {
return (int)(a+b);
}
#
With 4.1.0 i686-unknown-linux-gnu target:
# gcc -O2 m.c -S
# cat m.s
...
.type todouble, @function
todouble:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
fnstcw -2(%ebp)
fldl 16(%ebp)
faddl 8(%ebp)
movzwl -2(%ebp), %eax
orw $3072, %ax
movw %ax, -4(%ebp)
fldcw -4(%ebp)
fistpl -8(%ebp)
fldcw -2(%ebp)
movl -8(%ebp), %eax
leave
ret
...
With x86_64-unknown-linux-gnu (without -mfpmath=387):
# gcc -O2 m.c -S
# cat m.s
...
todouble:
.LFB2:
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
ret
With x86_64-unknown-linux-gnu with -mfpmath=387:
# gcc -O2 m.c -mfpmath=387 -S
# cat m.s
...
todouble:
.LFB2:
movsd %xmm0, -8(%rsp)
fldl -8(%rsp)
movsd %xmm1, -8(%rsp)
fldl -8(%rsp)
faddp %st, %st(1)
fstpl -8(%rsp)
movlpd -8(%rsp), %xmm0
cvttsd2si %xmm0, %eax
ret
#
All three codes can behave differently.
There's no doubt that using cvt* is faster, but that's not the point either.
I'm arguing that the purpose of -mfpmath=387 is to be compatible with 387
behavior, hence it should imply -mno-sse.
The fact that -mfpmath=sse exists implies that -mfpmath=387 turns off sse
(and that's what the description of -mfpmath=387 says).
Clearly this is not the current behavior of -mfpmath=387 - so if this behavior
is not going to be fixed, at the least,
the documentation should be updated to reflect that.
Having said that,
-mno-sse is an acceptable workaround so I won't pursue the bug anymore.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29337