public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/35202]  New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno
@ 2008-02-14 22:03 jsm28 at gcc dot gnu dot org
  2008-02-14 22:10 ` [Bug tree-optimization/35202] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-02-14 22:03 UTC (permalink / raw)
  To: gcc-bugs

GCC converts calls such as (float)exp((double)f), where f is a float, into
calls to the corresponding mathematical functions for float, such as expf.

However, if the result overflows the range of float but not that of double, the
conversion is unsafe with -fmath-errno (on by default on most targets): errno
may be set by the call to the float function but not by the call to the double
function, so the compiler may be wrongly causing errno to be set for such
arguments.

This problem applies to all of the functions where the result for some float
argument overflows the range of float but not double.

(This is a regression from the compiler versions without this optimization.)


-- 
           Summary: [4.1/4.2/4.3 Regression] exp->expf transformation
                    incorrect with -fmath-errno
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org


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


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

* [Bug tree-optimization/35202] [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
@ 2008-02-14 22:10 ` pinskia at gcc dot gnu dot org
  2008-02-14 23:02 ` rguenth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-02-14 22:10 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
   Target Milestone|---                         |4.1.3


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


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

* [Bug tree-optimization/35202] [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
  2008-02-14 22:10 ` [Bug tree-optimization/35202] " pinskia at gcc dot gnu dot org
@ 2008-02-14 23:02 ` rguenth at gcc dot gnu dot org
  2008-02-14 23:10 ` joseph at codesourcery dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-14 23:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2008-02-14 23:01 -------
There are more problems with -ferrno-math, see also PR29887.  It is btw unclear
to me whether -ferrno-math is supposed to preserve errno handling of whatever
the underlying libm provides or if it should actively do errno handling for
errors required by the standard or also for those that are optional by
the standard.  That is specifically how this option relates to 7.12.1,
especially if -ferrno-math effectively constrains the value of math_errhandling
or makes GCC assume a certain value of it.

Also what the effects of -ferrno-math are on the subtle difference of
"a ... error occurs" and "a ... error may occur".

Clarification would be much appreciated here, and I would like to effectively
make our default (-ferrno-math -ftrapping-math) be changed to
-fno-errno-math -ftrapping-math and providing math_errhandling ==
MATH_ERREXCEPT
by GCC, overriding the library.

Actually 7.12.1 does not say that errno is untouched if math_errhandling ==
MATH_ERREXCEPT, or does it do so implicitly?

Yet another reason why separating the math runtime from GCC is bad :(


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
           Keywords|                            |wrong-code


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


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

* [Bug tree-optimization/35202] [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
  2008-02-14 22:10 ` [Bug tree-optimization/35202] " pinskia at gcc dot gnu dot org
  2008-02-14 23:02 ` rguenth at gcc dot gnu dot org
@ 2008-02-14 23:10 ` joseph at codesourcery dot com
  2008-02-15 15:51 ` rguenth at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2008-02-14 23:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from joseph at codesourcery dot com  2008-02-14 23:09 -------
Subject: Re:  [4.1/4.2/4.3 Regression] exp->expf
 transformation incorrect with -fmath-errno

On Thu, 14 Feb 2008, rguenth at gcc dot gnu dot org wrote:

> Clarification would be much appreciated here, and I would like to effectively
> make our default (-ferrno-math -ftrapping-math) be changed to
> -fno-errno-math -ftrapping-math and providing math_errhandling ==
> MATH_ERREXCEPT
> by GCC, overriding the library.

Allowing this (not setting errno in certain cases) is an incompatible 
quiet change in C99 relative to C90, so I'm not convinced it's a good idea 
even in C99 mode.


-- 


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


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

* [Bug tree-optimization/35202] [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-02-14 23:10 ` joseph at codesourcery dot com
@ 2008-02-15 15:51 ` rguenth at gcc dot gnu dot org
  2008-02-15 15:54 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-15 15:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2008-02-15 15:50 -------
Ok, so with -fmath-errno the middle-end has to assume that the C library will
set errno appropriately for all math functions this is specified, even if
optional.  Right?  So we could at most detect at compile-time if there is a
macro named math_errhandling and defined to a constant by the library that
says it doesn't set errno and in this case clear -fmath-errno?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-02-15 15:50:39
               date|                            |


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


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

* [Bug tree-optimization/35202] [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-02-15 15:51 ` rguenth at gcc dot gnu dot org
@ 2008-02-15 15:54 ` rguenth at gcc dot gnu dot org
  2008-02-15 21:51 ` joseph at codesourcery dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-02-15 15:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-02-15 15:53 -------
The code that does this transformation is in convert.c:convert_to_real;
auditing
of all cases is required.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


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

* [Bug tree-optimization/35202] [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-02-15 15:54 ` rguenth at gcc dot gnu dot org
@ 2008-02-15 21:51 ` joseph at codesourcery dot com
  2008-07-04 22:34 ` [Bug tree-optimization/35202] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: joseph at codesourcery dot com @ 2008-02-15 21:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from joseph at codesourcery dot com  2008-02-15 21:50 -------
Subject: Re:  [4.1/4.2/4.3 Regression] exp->expf
 transformation incorrect with -fmath-errno

On Fri, 15 Feb 2008, rguenth at gcc dot gnu dot org wrote:

> Ok, so with -fmath-errno the middle-end has to assume that the C library will
> set errno appropriately for all math functions this is specified, even if
> optional.  Right?  So we could at most detect at compile-time if there is a

Yes, I think the compiler should avoid losing errno settings from library 
functions.

> macro named math_errhandling and defined to a constant by the library that
> says it doesn't set errno and in this case clear -fmath-errno?

I don't think detecting the macro is a particularly useful idea, unlike 
hardcoding for particular targets as is done for Darwin.

I think the right way for the macro to be handled with glibc is for it to 
expand to a reference to a variable that libc sets at startup.  libc would 
set it based on information about the flags used to compile every 
translation unit in the program, including those that went into shared 
libraries loaded.  If something was compiled with -fno-math-errno, for 
example, some function calls in the program might not get errno settings, 
so the math_errhandling value should not indicate that errno is guaranteed 
to be set.  The information about flags used would be stored in object 
files using object attributes, and converted by the static linker to some 
form for libc to use.  (But there's no real point making the compiler 
generate those object attributes without agreement from the libc side.)


-- 


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


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

* [Bug tree-optimization/35202] [4.2/4.3/4.4 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-02-15 21:51 ` joseph at codesourcery dot com
@ 2008-07-04 22:34 ` jsm28 at gcc dot gnu dot org
  2009-01-25 18:29 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 22:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jsm28 at gcc dot gnu dot org  2008-07-04 22:33 -------
Closing 4.1 branch.


-- 

jsm28 at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.1/4.2/4.3/4.4 Regression]|[4.2/4.3/4.4 Regression]
                   |exp->expf transformation    |exp->expf transformation
                   |incorrect with -fmath-errno |incorrect with -fmath-errno
   Target Milestone|4.1.3                       |4.2.5


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


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

* [Bug tree-optimization/35202] [4.2/4.3/4.4 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-07-04 22:34 ` [Bug tree-optimization/35202] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
@ 2009-01-25 18:29 ` rguenth at gcc dot gnu dot org
  2009-02-09  9:35 ` rguenth at gcc dot gnu dot org
  2009-02-09  9:36 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-01-25 18:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2009-01-25 18:29 -------
I have a patch.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-02-15 15:50:39         |2009-01-25 18:29:32
               date|                            |


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


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

* [Bug tree-optimization/35202] [4.2/4.3/4.4 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-01-25 18:29 ` rguenth at gcc dot gnu dot org
@ 2009-02-09  9:35 ` rguenth at gcc dot gnu dot org
  2009-02-09  9:36 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-09  9:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from rguenth at gcc dot gnu dot org  2009-02-09 09:35 -------
Subject: Bug 35202

Author: rguenth
Date: Mon Feb  9 09:35:22 2009
New Revision: 144030

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144030
Log:
2009-02-09  Richard Guenther  <rguenther@suse.de>

        PR middle-end/35202
        * convert.c (convert_to_real): Disable (float)fn((double)x)
        to fnf(x) conversion if errno differences may occur and
        -fmath-errno is set.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/convert.c


-- 


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


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

* [Bug tree-optimization/35202] [4.2/4.3/4.4 Regression] exp->expf transformation incorrect with -fmath-errno
  2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-02-09  9:35 ` rguenth at gcc dot gnu dot org
@ 2009-02-09  9:36 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-09  9:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2009-02-09 09:36 -------
Fixed for trunk.  Not worth fixing on the branches.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|                            |4.2.4 4.3.4
      Known to work|                            |4.4.0
         Resolution|                            |FIXED
   Target Milestone|4.2.5                       |4.4.0


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


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

end of thread, other threads:[~2009-02-09  9:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-14 22:03 [Bug tree-optimization/35202] New: [4.1/4.2/4.3 Regression] exp->expf transformation incorrect with -fmath-errno jsm28 at gcc dot gnu dot org
2008-02-14 22:10 ` [Bug tree-optimization/35202] " pinskia at gcc dot gnu dot org
2008-02-14 23:02 ` rguenth at gcc dot gnu dot org
2008-02-14 23:10 ` joseph at codesourcery dot com
2008-02-15 15:51 ` rguenth at gcc dot gnu dot org
2008-02-15 15:54 ` rguenth at gcc dot gnu dot org
2008-02-15 21:51 ` joseph at codesourcery dot com
2008-07-04 22:34 ` [Bug tree-optimization/35202] [4.2/4.3/4.4 " jsm28 at gcc dot gnu dot org
2009-01-25 18:29 ` rguenth at gcc dot gnu dot org
2009-02-09  9:35 ` rguenth at gcc dot gnu dot org
2009-02-09  9:36 ` rguenth 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).