public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/30568]  New: -ftrapping-math should prevent folding/dead code stripping of some builtins
@ 2007-01-24  2:10 geoffk at gcc dot gnu dot org
  2007-01-24  2:11 ` [Bug middle-end/30568] " geoffk at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2007-01-24  2:10 UTC (permalink / raw)
  To: gcc-bugs

This program:

#include <stdio.h>
#include <math.h>
#include <fenv.h>

main()
{
unsigned flags;

feclearexcept(FE_ALL_EXCEPT);
(void)acos(1.1);
flags = fetestexcept(FE_ALL_EXCEPT);

printf("(void)acos( %e ) gives flags 0x%8x\n", 1.1, flags & FE_ALL_EXCEPT);
}

when compiled with -ftrapping-math, should show that some flags are set,
FE_INVALID I think (maybe others).  Instead it shows that no flags are set,
because GCC has completely folded out the call to acos().


-- 
           Summary: -ftrapping-math should prevent folding/dead code
                    stripping of some builtins
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: geoffk at gcc dot gnu dot org
GCC target triplet: *-*-darwin*


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


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

* [Bug middle-end/30568] -ftrapping-math should prevent folding/dead code stripping of some builtins
  2007-01-24  2:10 [Bug middle-end/30568] New: -ftrapping-math should prevent folding/dead code stripping of some builtins geoffk at gcc dot gnu dot org
@ 2007-01-24  2:11 ` geoffk at gcc dot gnu dot org
  2007-01-24  2:37 ` joseph at codesourcery dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: geoffk at gcc dot gnu dot org @ 2007-01-24  2:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from geoffk at gcc dot gnu dot org  2007-01-24 02:11 -------
Other builtins where this can apply are pow() and lround().


-- 


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


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

* [Bug middle-end/30568] -ftrapping-math should prevent folding/dead code stripping of some builtins
  2007-01-24  2:10 [Bug middle-end/30568] New: -ftrapping-math should prevent folding/dead code stripping of some builtins geoffk at gcc dot gnu dot org
  2007-01-24  2:11 ` [Bug middle-end/30568] " geoffk at gcc dot gnu dot org
@ 2007-01-24  2:37 ` joseph at codesourcery dot com
  2007-01-24  6:54 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: joseph at codesourcery dot com @ 2007-01-24  2:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from joseph at codesourcery dot com  2007-01-24 02:37 -------
Subject: Re:   New: -ftrapping-math should prevent
 folding/dead code stripping of some builtins

On Wed, 24 Jan 2007, geoffk at gcc dot gnu dot org wrote:

> when compiled with -ftrapping-math, should show that some flags are set,
> FE_INVALID I think (maybe others).  Instead it shows that no flags are set,
> because GCC has completely folded out the call to acos().

I think this is the same as bug 29186.


-- 


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


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

* [Bug middle-end/30568] -ftrapping-math should prevent folding/dead code stripping of some builtins
  2007-01-24  2:10 [Bug middle-end/30568] New: -ftrapping-math should prevent folding/dead code stripping of some builtins geoffk at gcc dot gnu dot org
  2007-01-24  2:11 ` [Bug middle-end/30568] " geoffk at gcc dot gnu dot org
  2007-01-24  2:37 ` joseph at codesourcery dot com
@ 2007-01-24  6:54 ` pinskia at gcc dot gnu dot org
  2007-01-24 10:25 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-24  6:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-01-24 06:54 -------
Part of the problem here is that darwin turns on no math-errno by default which
turns the builtin functions into pure functions and since we don't use the 
result, we DCE it.
pure functions are not allowed to trap IIRC the rules.


-- 


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


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

* [Bug middle-end/30568] -ftrapping-math should prevent folding/dead code stripping of some builtins
  2007-01-24  2:10 [Bug middle-end/30568] New: -ftrapping-math should prevent folding/dead code stripping of some builtins geoffk at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-01-24  6:54 ` pinskia at gcc dot gnu dot org
@ 2007-01-24 10:25 ` rguenth at gcc dot gnu dot org
  2009-02-15 20:09 ` kreckel at ginac dot de
  2009-12-29 21:51 ` fxcoudert at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-01-24 10:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2007-01-24 10:25 -------
This is an (easier) variant of PR29186.  Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |29186
              nThis|                            |
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-01-24 10:25:28
               date|                            |


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


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

* [Bug middle-end/30568] -ftrapping-math should prevent folding/dead code stripping of some builtins
  2007-01-24  2:10 [Bug middle-end/30568] New: -ftrapping-math should prevent folding/dead code stripping of some builtins geoffk at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-01-24 10:25 ` rguenth at gcc dot gnu dot org
@ 2009-02-15 20:09 ` kreckel at ginac dot de
  2009-12-29 21:51 ` fxcoudert at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: kreckel at ginac dot de @ 2009-02-15 20:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from kreckel at ginac dot de  2009-02-15 20:09 -------
(In reply to comment #4)
> This is an (easier) variant of PR29186.  Confirmed.

The difference between this bug and PR29186 is that this one here can be
explained by failing to correctly treat the exception flags at compile-time
(after const folding), whereas PR29186 is all about code movements that make
these flags unreliable during runtime.


-- 


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


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

* [Bug middle-end/30568] -ftrapping-math should prevent folding/dead code stripping of some builtins
  2007-01-24  2:10 [Bug middle-end/30568] New: -ftrapping-math should prevent folding/dead code stripping of some builtins geoffk at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-02-15 20:09 ` kreckel at ginac dot de
@ 2009-12-29 21:51 ` fxcoudert at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-12-29 21:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from fxcoudert at gcc dot gnu dot org  2009-12-29 21:51 -------
Confirming this as generic, non Darwin-specific bug. On i686-linux with current
trunk:

$ cat a.c
#include <stdio.h>
#include <math.h>
#include <fenv.h>

main()
{
unsigned flags;

feclearexcept(FE_ALL_EXCEPT);
(void)acos(1.1);
flags = fetestexcept(FE_ALL_EXCEPT);

printf("(void)acos( %e ) gives flags 0x%8x\n", 1.1, flags & FE_ALL_EXCEPT);
}
$ gcc a.c -ftrapping-math -O0 -fno-math-errno -lm && ./a.out
(void)acos( 1.100000e+00 ) gives flags 0x       0


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|*-*-darwin*                 |
   Last reconfirmed|2007-01-24 10:25:28         |2009-12-29 21:51:37
               date|                            |


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


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

end of thread, other threads:[~2009-12-29 21:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-24  2:10 [Bug middle-end/30568] New: -ftrapping-math should prevent folding/dead code stripping of some builtins geoffk at gcc dot gnu dot org
2007-01-24  2:11 ` [Bug middle-end/30568] " geoffk at gcc dot gnu dot org
2007-01-24  2:37 ` joseph at codesourcery dot com
2007-01-24  6:54 ` pinskia at gcc dot gnu dot org
2007-01-24 10:25 ` rguenth at gcc dot gnu dot org
2009-02-15 20:09 ` kreckel at ginac dot de
2009-12-29 21:51 ` fxcoudert at gcc dot gnu dot org

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