public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50195] New: Linking time eroor with -fast-math -O0
@ 2011-08-26 13:22 vbyakovl23 at gmail dot com
  2011-08-26 13:26 ` [Bug middle-end/50195] [4.7 Regression] Linking time error " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vbyakovl23 at gmail dot com @ 2011-08-26 13:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50195

             Bug #: 50195
           Summary: Linking time eroor with -fast-math -O0
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vbyakovl23@gmail.com


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. 

>From Richard Guenther:
No, I think we should avoid most of the builtin related folding at -O0.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/50195] [4.7 Regression] Linking time error with -fast-math -O0
  2011-08-26 13:22 [Bug c/50195] New: Linking time eroor with -fast-math -O0 vbyakovl23 at gmail dot com
@ 2011-08-26 13:26 ` rguenth at gcc dot gnu.org
  2011-10-10 12:24 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-26 13:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50195

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-08-26
          Component|c                           |middle-end
   Target Milestone|---                         |4.7.0
            Summary|Linking time eroor with     |[4.7 Regression] Linking
                   |-fast-math -O0              |time error with -fast-math
                   |                            |-O0
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-26 13:22:07 UTC ---
Confirmed.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/50195] [4.7 Regression] Linking time error with -fast-math -O0
  2011-08-26 13:22 [Bug c/50195] New: Linking time eroor with -fast-math -O0 vbyakovl23 at gmail dot com
  2011-08-26 13:26 ` [Bug middle-end/50195] [4.7 Regression] Linking time error " rguenth at gcc dot gnu.org
@ 2011-10-10 12:24 ` rguenth at gcc dot gnu.org
  2011-10-10 13:04 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-10 12:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50195

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-10 12:24:02 UTC ---
The folding is guarded with optimize_function_for_speed_p (), but that always
returns true for -O0 ...

Honza, should the _for_speed_p () functions in predict.c be optimize && ...
instead?


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/50195] [4.7 Regression] Linking time error with -fast-math -O0
  2011-08-26 13:22 [Bug c/50195] New: Linking time eroor with -fast-math -O0 vbyakovl23 at gmail dot com
  2011-08-26 13:26 ` [Bug middle-end/50195] [4.7 Regression] Linking time error " rguenth at gcc dot gnu.org
  2011-10-10 12:24 ` rguenth at gcc dot gnu.org
@ 2011-10-10 13:04 ` rguenth at gcc dot gnu.org
  2011-10-10 14:27 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-10 13:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50195

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-10 13:03:32 UTC ---
Mine.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/50195] [4.7 Regression] Linking time error with -fast-math -O0
  2011-08-26 13:22 [Bug c/50195] New: Linking time eroor with -fast-math -O0 vbyakovl23 at gmail dot com
                   ` (2 preceding siblings ...)
  2011-10-10 13:04 ` rguenth at gcc dot gnu.org
@ 2011-10-10 14:27 ` rguenth at gcc dot gnu.org
  2011-10-10 15:48 ` rguenth at gcc dot gnu.org
  2011-10-10 16:26 ` hubicka at ucw dot cz
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-10 14:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50195

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-10 14:25:43 UTC ---
Author: rguenth
Date: Mon Oct 10 14:25:34 2011
New Revision: 179752

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179752
Log:
2011-10-10  Richard Guenther  <rguenther@suse.de>

    PR middle-end/50195
    * fold-const.c (fold_binary_loc): Canonicalize x*x to pow (x, 2)
    only when optimizing.

    * gcc.dg/builtins-47.c: Optimize.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/builtins-47.c


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/50195] [4.7 Regression] Linking time error with -fast-math -O0
  2011-08-26 13:22 [Bug c/50195] New: Linking time eroor with -fast-math -O0 vbyakovl23 at gmail dot com
                   ` (3 preceding siblings ...)
  2011-10-10 14:27 ` rguenth at gcc dot gnu.org
@ 2011-10-10 15:48 ` rguenth at gcc dot gnu.org
  2011-10-10 16:26 ` hubicka at ucw dot cz
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-10-10 15:48 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50195

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-10 15:46:55 UTC ---
Fixed.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug middle-end/50195] [4.7 Regression] Linking time error with -fast-math -O0
  2011-08-26 13:22 [Bug c/50195] New: Linking time eroor with -fast-math -O0 vbyakovl23 at gmail dot com
                   ` (4 preceding siblings ...)
  2011-10-10 15:48 ` rguenth at gcc dot gnu.org
@ 2011-10-10 16:26 ` hubicka at ucw dot cz
  5 siblings, 0 replies; 7+ messages in thread
From: hubicka at ucw dot cz @ 2011-10-10 16:26 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50195

--- Comment #6 from Jan Hubicka <hubicka at ucw dot cz> 2011-10-10 16:25:15 UTC ---
> The folding is guarded with optimize_function_for_speed_p (), but that always
> returns true for -O0 ...
> 
> Honza, should the _for_speed_p () functions in predict.c be optimize && ...
> instead?

This is how we always behaved (i.e. when not optimizing we had optimize_size
false).
Switching the default may make sense, we might also hit some -Os bugs since -O0
gets more testing.

Honza


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-10-10 16:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-26 13:22 [Bug c/50195] New: Linking time eroor with -fast-math -O0 vbyakovl23 at gmail dot com
2011-08-26 13:26 ` [Bug middle-end/50195] [4.7 Regression] Linking time error " rguenth at gcc dot gnu.org
2011-10-10 12:24 ` rguenth at gcc dot gnu.org
2011-10-10 13:04 ` rguenth at gcc dot gnu.org
2011-10-10 14:27 ` rguenth at gcc dot gnu.org
2011-10-10 15:48 ` rguenth at gcc dot gnu.org
2011-10-10 16:26 ` hubicka at ucw dot cz

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).