public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: tevessen@pop-koeln.de
To: gcc-gnats@gcc.gnu.org
Subject: target/6041: x86: No inline FPU code generated even if arch says target always has FPU
Date: Fri, 22 Mar 2002 08:46:00 -0000	[thread overview]
Message-ID: <20020322163846.19506.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2302 bytes --]


>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:


             reply	other threads:[~2002-03-22 16:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-22  8:46 tevessen [this message]
2002-03-29 15:31 rth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020322163846.19506.qmail@sources.redhat.com \
    --to=tevessen@pop-koeln.de \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).