target/6041: x86: No inline FPU code generated even if arch says target always has FPU
tevessen@pop-koeln.de
tevessen@pop-koeln.de
Fri Mar 22 08:46:00 GMT 2002
>Number: 6041
>Category: target
>Synopsis: x86: No inline FPU code generated even if arch says target always has FPU
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: pessimizes-code
>Submitter-Id: net
>Arrival-Date: Fri Mar 22 08:46:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Johannes Tevessen
>Release: gcc version 3.0.3
>Organization:
>Environment:
Linux 2.4.17 #4 Mon Feb 18 12:29:18 CET 2002 i686 unknown
BFD: GNU assembler version 2.11.90.0.8 (i386-redhat-linux) using BFD version 2.11.90.0.8
>Description:
The info docs say:
"`-mno-fancy-math-387'
    Some 387 emulators do not support the `sin', `cos' and `sqrt'
    instructions for the 387. Specify this option to avoid generating
    those instructions. This option is the default on FreeBSD. As of
    revision 2.6.1, these instructions are not generated unless you
    also use the `-ffast-math' switch."
Well, reading this made me curious and I wrote a
simple piece of code like this:
#include <math.h>
double sindbl (double inp) {
return sin (inp);
}
gives (-march=athlon -O9):
sindbl:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
leave
jmp sin
so there's actually a subfunction call to sin() generated
for something that i586/i686/athlon/k6 can easily
do with inline asm.
-ffast-math changes this:
sindbl:
pushl %ebp
movl %esp, %ebp
fldl 8(%ebp)
#APP
fsin
#NO_APP
popl %ebp
ret
The point being that i586 upto athlon always
include an FPU, so there's no need to look for
FPU software emulator support unless explicitly
wanted by the user.
Also, -ffast-math turns on some more optimizations
that may be unwanted.
And: Maybe another bug: Just adding
-mfancy-math-387 does _not_ produce inline asm
as I had expected. It _also_ calls sin() in 3.0.3,
so the docs are wrong here, too.
>How-To-Repeat:
Create any C file, #include <math.h>, use something
like sin(), compile with optimization and -march=i686
(or similar) and inspect object file or gcc -S output.
>Fix:
Make inline FPU asm instructions the default for -march
i586, i686, k6, athlon.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list