From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15831 invoked by alias); 1 Nov 2012 10:12:10 -0000 Received: (qmail 15680 invoked by uid 48); 1 Nov 2012 10:11:47 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/55162] Loop ivopts cuts off top bits of loop counter Date: Thu, 01 Nov 2012 10:12:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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-11/txt/msg00027.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55162 --- Comment #1 from Oleg Endo 2012-11-01 10:11:46 UTC --- (In reply to comment #0) > The same could be done on SH, too (comparing against the end address instead of > using a loop counter), but it would add a loop setup overhead. In the optimal > case the above function would result in the following SH code: > > tst r5,r5 > bt/s .L6 > mov #0,r0 > .L3: > mov.l @r4+,r1 > dt r5 > bf/s .L3 > add r1,r0 > .L6: > rts > nop > ... which is the case if '*x++' is used instead of 'x[i]': int test (int* x, unsigned int c) { int s = 0; unsigned int i; for (i = 0; i < c; ++i) s += *x++; return s; }