From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6445 invoked by alias); 11 Nov 2013 16:38:33 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 6411 invoked by uid 55); 11 Nov 2013 16:38:30 -0000 From: "joseph at codesourcery dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/34678] Optimization generates incorrect code with -frounding-math option (#pragma STDC FENV_ACCESS not implemented) Date: Mon, 11 Nov 2013 16:38:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: joseph at codesourcery dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-11/txt/msg01065.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34678 --- Comment #22 from joseph at codesourcery dot com --- On Mon, 11 Nov 2013, nmm1 at cam dot ac.uk wrote: > There are also very strong grounds for not wanting IEEE 754 support by > default, anyway, because of the performance impact and because a lot of > programs won't reset the state before calling external functions (and > hence may well give wrong answers). That is especially true if the code > is used within a C++ program or uses GPUs or some SIMD units - let alone > OpenMP :-( Note also that the documented default is -ftrapping-math -fno-rounding-math. I suspect that if -ftrapping-math actually implemented everything required for the floating-point exceptions aspects of FENV_ACCESS, it would be just as bad for optimization as -frounding-math - it would disallow constant-folding inexact floating-point expressions because that would eliminate the side effect of raising the "inexact" exception, for example (just as -frounding-math does disable such constant folding, although not in all cases it should, because the result depends on the rounding mode), and would mean a value computed before a function call can't be reused for the same computation after that call because the computation might raise exceptions that the function call could have cleared (just as -frounding-math should prevent such reuse because the call might change the rounding mode). So a key part of actually making rounding modes and exceptions work reliably would be working out a definition of GCC's default mode that allows more or less the same optimizations as at present, while allowing users wanting the full support (and consequent optimization cost) to specify the appropriate command-line options or FENV_ACCESS pragma to enable it.