From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24114 invoked by alias); 9 Dec 2010 17:57:05 -0000 Received: (qmail 24103 invoked by uid 22791); 9 Dec 2010 17:57:04 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50,TW_DN,TW_LB 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; Thu, 09 Dec 2010 17:56:59 +0000 From: "meissner at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/46854] PowerPC optimization regression 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: X-Bugzilla-Severity: normal X-Bugzilla-Who: meissner 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: --- X-Bugzilla-Changed-Fields: Status Last reconfirmed CC Ever Confirmed 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 Date: Thu, 09 Dec 2010 17:57:00 -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 X-SW-Source: 2010-12/txt/msg01022.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46854 Michael Meissner changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2010.12.09 17:56:39 CC| |meissner at gcc dot gnu.org Ever Confirmed|0 |1 --- Comment #2 from Michael Meissner 2010-12-09 17:56:39 UTC --- Note, -O2 generates mostly the code you want, except that it looks the address of the string twice: Here is the code generated with a 4.4.4 based compiler (the compiler happens to be the IBM advance toolchain, version 3.0-1) using -O2 -m32 (-O1/-O3 generate the same code): test: mr. 0,3 mtctr 0 beq 0,.L10 lis 3,.LANCHOR0@ha la 3,.LANCHOR0@l(3) .p2align 4,,15 .L8: lbzu 0,1(3) cmpwi 7,0,0 bne 7,.L8 bdnz .L8 blr .L10: lis 3,.LANCHOR0@ha la 3,.LANCHOR0@l(3) blr The SLES 11SP1 system compiler, which is based on GCC 4.3.4 generates the same code. However, the GCC 4.6 trunk seems to have regressed slightly with -O2 or -O3, in that it does not track that the lbzu updates the pointer, but maintains its own copy: mr. 0,3 mtctr 0 beq- 0,.L5 lis 3,.LANCHOR0@ha la 3,.LANCHOR0@l(3) .L4: mr 9,3 .L3: lbzu 0,1(9) addi 3,3,1 cmpwi 7,0,0 bne+ 7,.L3 bdnz .L4 blr .L5: lis 3,.LANCHOR0@ha la 3,.LANCHOR0@l(3) blr Trunk with -Os does generate the two comparisons: mr 9,3 lis 3,.LANCHOR0@ha la 3,.LANCHOR0@l(3) b .L2 .L5: mr 11,3 addi 3,3,1 lbz 0,1(11) cmpwi 7,0,0 bne+ 7,.L5 addi 9,9,-1 .L2: cmpwi 7,9,0 bne+ 7,.L5 blr So, there are two bugs in this. One that -Os generates larger code than -O2, and the code regression for GCC 4.6.