--- Comment #8 from uros at kss-loka dot si 2006-10-05 07:08 ---
try -O2 -msse2, you get:
_Z8todoubledd:
subl$12, %esp
fldl24(%esp)
faddl 16(%esp)
fstpl (%esp)
movsd (%esp), %xmm0
addl$12, %esp
cvttsd2si
--- Comment #3 from uros at kss-loka dot si 2006-10-04 06:46 ---
I'm afraid you're missing my point.
The problem is that for 64-bit and 32-bit floating-point to integer
conversion,
x86 (32bit) target uses fistp* whereas x86_64 (64-bit) target uses cvt* WHEN
-mfpmath=387.
This
--- Comment #4 from pinskia at gcc dot gnu dot org 2006-10-05 04:38 ---
Actually the reason why it uses cvttsd2si is two fold, first cvttsd2si does not
need to act on a SSE register which is where the argument is passed in.
In fact we use cvttsd2si for 32bit also which actually
--- Comment #5 from pinskia at gcc dot gnu dot org 2006-10-05 04:45 ---
(In reply to comment #0)
This makes a difference if/when the extra precision of 387 makes difference to
the conversion - which -mfpmath=387 is supposed to prevent.
that is only done when doing lots of math so then
--- 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:
On Thu, 2006-10-05 at 05:00 +, seongbae dot park at gmail dot com
wrote:
With 4.1.0 i686-unknown-linux-gnu target:
# gcc -O2 m.c -S
try -O2 -msse2, you get:
_Z8todoubledd:
subl$12, %esp
fldl24(%esp)
faddl 16(%esp)
fstpl (%esp)
movsd
--- Comment #7 from pinskia at physics dot uc dot edu 2006-10-05 05:05
---
Subject: Re: -mfpmath=387 doesn't use fistp for
double-to-integer conversion
On Thu, 2006-10-05 at 05:00 +, seongbae dot park at gmail dot com
wrote:
With 4.1.0 i686-unknown-linux-gnu target:
#
--- Comment #1 from pluto at agmk dot net 2006-10-03 21:57 ---
(In reply to comment #0)
This makes a difference if/when the extra precision of 387 makes difference
for an extra prescision try to use a `long double'.
$ cat fp.cpp
int convert( long double x ) { return (int)x; }
int
--- Comment #2 from seongbae dot park at gmail dot com 2006-10-03 23:37
---
(In reply to comment #1)
(In reply to comment #0)
This makes a difference if/when the extra precision of 387 makes difference
for an extra prescision try to use a `long double'.
I'm afraid you're