From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 849 invoked by alias); 21 Feb 2012 13:28:32 -0000 Received: (qmail 836 invoked by uid 22791); 21 Feb 2012 13:28:31 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Feb 2012 13:28:18 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/52326] [4.6 Regression] float result incorrect with -O1 and calling external function. Date: Tue, 21 Feb 2012 13:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.3 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-02/txt/msg02073.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52326 --- Comment #2 from Richard Guenther 2012-02-21 13:27:23 UTC --- Reduced single-file testcase, fails at -O1: float fabsf(float x); void abort (void); static float minf(float a, float b) { return (a < b) ? a: b; } static float maxf(float a, float b) { return (a > b) ? a: b; } struct EC { float fftout; int extragainOn; }; static float __attribute__((noinline)) foo (float a) { asm(""); return a; } static struct EC * __attribute__((noinline)) ec_create(void) { static struct EC p; p.fftout = 1.234567f; p.extragainOn = 1; return &p; } static float ec_process(struct EC *p, float beflev, float estlev) { float fullgCorr; float extrag; fullgCorr = maxf(0.0f, beflev - estlev) / beflev; extrag = 1.0f; if (p->extragainOn) extrag = minf(1.0f, fullgCorr); foo(0.0f); return extrag * p->fftout; } int main(void) { unsigned int i = 0; float beflev[] = {11.6f, 1.0f}; float estlev[] = {11.5f, 1.0f}; float output; struct EC *p = ec_create(); /* NOTE: If the for-loop is removed, the error disappears */ for (i = 0; i < 1; i++) output = ec_process(p, beflev[i], estlev[i]); if (fabsf(output - 0.010643f) < 1e-5f) return 0; else abort (); }