Summary: | gcc performs invalid optimization with float operations when different rounding mode. | ||
---|---|---|---|
Product: | gcc | Reporter: | goualard |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | SUSPENDED --- | ||
Severity: | enhancement | CC: | gcc-bugs, rth, vincent-gcc |
Priority: | P3 | Keywords: | wrong-code |
Version: | 2.95.2 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2005-12-28 06:35:21 | |
Bug Depends on: | |||
Bug Blocks: | 16989 |
Description
goualard
2000-09-28 06:56:01 UTC
From: "Joseph S. Myers" <jsm28@cam.ac.uk> To: goualard@cwi.nl Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org Subject: Re: optimization/576: gcc performs invalid optimization with float operations. Date: Thu, 28 Sep 2000 16:33:45 +0100 (BST) On 28 Sep 2000 goualard@cwi.nl wrote: > gcc performs optimizations that are invalid for some > floating-point computations when the rounding direction > is set towards +infinity or -infinity. As shown in > the code example, trivial identities do no longer hold. For this to work properly, according to the C99 standard you must use "#pragma STDC FENV_ACCESS ON". GCC does not yet support the C99 standard pragmas, but hopefully it will do so in future. (Note also that using the <fenv.h> function fesetround() is more portable than using an asm.) This should for now be considered a missing feature in GCC (documented as missing at http://gcc.gnu.org/c99status.html). See http://gcc.gnu.org/contribute.html and http://gcc.gnu.org/contributewhy.html if you want to contribute an implementation; I don't know if anyone is working on this. -- Joseph S. Myers jsm28@cam.ac.uk State-Changed-From-To: open->suspended State-Changed-Why: As Joseph mentioned, unimplemented C99 features are required. From: rth@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, goualard@cwi.nl, nobody@gcc.gnu.org Cc: Subject: Re: optimization/576 Date: 16 Jan 2001 15:17:24 -0000 Synopsis: gcc performs invalid optimization with float operations. State-Changed-From-To: open->suspended State-Changed-By: rth State-Changed-When: Tue Jan 16 07:17:24 2001 State-Changed-Why: As Joseph mentioned, unimplemented C99 features are required. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=576&database=gcc Subject: Bug 576 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2005-01-21 17:54:27 Modified files: gcc : ChangeLog real.c real.h fold-const.c simplify-rtx.c Log message: PR rtl-optimization/576 * real.c (real_arithmetic): Change return type from void to bool to return an indication that the result may be inexact. * real.h (real_arithmeric): Update prototype. * fold-const.c (const_binop): Don't constant fold floating point expressions when the user specifies -frounding-math and the result may depend upon the run-time rounding mode. (fold_convert_const_real_from_real): Clean-up. (fold_initializer): Ignore flag_rounding_math for initializers. * simplify-rtx.c (simplify_binary_operation): Likewise, don't constant fold FP operations with flag_rounding_math if the result may depend upon the run-time rounding mode. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7220&r2=2.7221 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/real.c.diff?cvsroot=gcc&r1=1.149&r2=1.150 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/real.h.diff?cvsroot=gcc&r1=1.79&r2=1.80 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.495&r2=1.496 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/simplify-rtx.c.diff?cvsroot=gcc&r1=1.222&r2=1.223 The -frounding-math option should solve the issue on this particular example. But on my machine, ld gives an "undefined reference to `_up'" error. For a more general bug, see PR34678. (In reply to Vincent Lefèvre from comment #5) > The -frounding-math option should solve the issue on this particular > example. But on my machine, ld gives an "undefined reference to `_up'" error. That is because the code is GNU C90 and not C++ . (In reply to Andrew Pinski from comment #6) > That is because the code is GNU C90 and not C++ . I've used gcc, not g++. But this fails even with -std=gnu90. |