public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Vladimir Yakovlev <vbyakovl23@gmail.com>
Cc: gcc@gcc.gnu.org
Subject: Re: linking time eroor with -fast-math -O0
Date: Fri, 26 Aug 2011 12:55:00 -0000	[thread overview]
Message-ID: <CAFiYyc1BD1+k=nxrp1YZtHYPXMeE9nRsh9S5y1bPY_SGEDsy_w@mail.gmail.com> (raw)
In-Reply-To: <CAK1BsWpuYaPPoetu96e=2H8NesLZrSFwGnZGow88vph-Ay+4kA@mail.gmail.com>

On Fri, Aug 26, 2011 at 2:52 PM, Vladimir Yakovlev <vbyakovl23@gmail.com> wrote:
> Hi,
>
> Following test fails in linking if compiled with ffast-math and O0,
> but it compiled successfully with ffast-math and O2. Also no problem
> if -lm is added.
>
> $ cat t.c
> #include <stdio.h>
>
> float foo(float x)
> {
>   float y = 0;
>   while (x > 0.00000001) {
>     y += x*x*x*x*x*x*x*x*x*x*x*x*x;
>     x = x/2;
>   }
>   return y;
> }
>
> int main (int argc, char    *argv[])
> {
>  float y = atoi(argv[1]);
>  printf("%f\n", foo(y));
>  return 0;
> }
>
>
> $ gcc  -ffast-math -O0   t.c
> /tmp/cccA1sUB.o: In function `foo':
> t.c:(.text+0x2c): undefined reference to `powf'
> collect2: error: ld returned 1 exit status
> $ gcc  -ffast-math -O2   t.c
> $ ./a.out 5
> 1220852096.000000
>
>
> FE with -ffast-math replaced x*x*...*x with __builtin_powf. Later with
> -O2 this call is replaced back into multiplications in sincos phase.
> The stability with -O0 is because sincos phase doesn't work on -O0.
>
> I think we must avoid doing this optimization in FE and turn off
> -ffast-math if -O0 is used. Your opinion.

No, I think we should avoid most of the builtin related folding at -O0.

Can you open a bugreport on gcc.gnu.org/bugzilla please?

Thanks,
Richard.

> Thanks,
> Vladimir
>

      reply	other threads:[~2011-08-26 12:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26 12:52 Vladimir Yakovlev
2011-08-26 12:55 ` Richard Guenther [this message]

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='CAFiYyc1BD1+k=nxrp1YZtHYPXMeE9nRsh9S5y1bPY_SGEDsy_w@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=vbyakovl23@gmail.com \
    /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).