From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18277 invoked by alias); 14 Dec 2012 13:49:39 -0000 Received: (qmail 18140 invoked by uid 48); 14 Dec 2012 13:49:04 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/55555] [4.8 Regression] miscompilation at -O2 (number_of_iterations) Date: Fri, 14 Dec 2012 13:49: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-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 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-12/txt/msg01439.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55555 --- Comment #8 from Richard Biener 2012-12-14 13:49:02 UTC --- (In reply to comment #7) > I've tried to rewrite this as C, but managed to turn it into something that is > miscompiled at a different spot. The fortran testcase starts having > __builtin_unreachable () in it in the *.cunroll pass, this one already in > *.cunrolli pass. Still, I believe it doesn't do any out of bounds access > anywhere. -O2 on x86_64-linux. > > double s[4] = { 1.0, 2.0, 3.0, 4.0 }, pol_x[2] = { 5.0, 6.0 }; > > __attribute__((noinline)) int > foo (void) > { > double coef_x[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; > int lxp = 0; > if (lxp <= 1) > do > { > double t = pol_x[lxp]; > long S; > long l = lxp * 4L - 1; > for (S = 1; S <= 4; S++) > coef_x[S + l] = coef_x[S + l] + s[S - 1] * t; > } > while (lxp++ != 1); > asm volatile ("" : : "r" (coef_x) : "memory"); > for (lxp = 0; lxp < 8; lxp++) > if (coef_x[lxp] != ((lxp & 3) + 1) * (5.0 + (lxp >= 4))) > __builtin_abort (); > return 1; > } > > int > main () > { > asm volatile ("" : : : "memory"); > if (!foo ()) > __builtin_abort (); > return 0; > } > > Works with r193067, fails with r193100, haven't tried to bisect exactly, but > would guess this is r193098 again. For the outer loop it prints: > > Analyzing # of iterations of loop 1 > exit condition [0, + , 1](no_overflow) != 1 > bounds on difference of bases: 1 ... 1 > result: > # of iterations 1, bounded by 1 > Loop 1 iterates 1 times. > Loop 1 iterates at most 1 times. > > but that is wrong, the outer loop iterates exactly 2 times. That's latch block executions, so one latch block execution is correct.