From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20676 invoked by alias); 9 May 2014 19:50:19 -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 20644 invoked by uid 48); 9 May 2014 19:50:16 -0000 From: "swarren at nvidia dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/61131] New: [4.8 regression] ARM -Os: incorrect code generation Date: Fri, 09 May 2014 19:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: swarren at nvidia dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: 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: 2014-05/txt/msg00870.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61131 Bug ID: 61131 Summary: [4.8 regression] ARM -Os: incorrect code generation Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: swarren at nvidia dot com Created attachment 32771 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32771&action=edit Source sample that exhibits the issue when compiled When running gcc 4.8 for ARM with -Os, the following function: int count_entries(struct s *p) { int i = 0; while (p->fd[i] >= 0 && i < MAX_COUNT) { i++; } return i; } ... gets compiled to essentially a no-op: 000083f8 : 83f8: e5900000 ldr r0, [r0] 83fc: e1e00000 mvn r0, r0 8400: e1a00fa0 lsr r0, r0, #31 8404: e12fff1e bx lr If I don't use -Os, then I get much larger, and working, code. If I swap the order of the two conditions in the while expression, I get working code: while (i < MAX_COUNT && p->fd[i] >= 0) { If I use gcc-4.7 insteaad, I get working code. A complete source sample is attached. The bug is NOT present in gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux.tar.xz, which is apparently GCC 4.7.2+svn197188. The bug IS present in gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux.tar.xz, which is apparently GCC 4.8.3+svn208968. I wasn't able to quickly track down any more recent gcc-4.8.x binaries, or gcc-4.9.x binaries. The bug IS present in some toolchain I received from a customer in directory name yocto/gcc-4.8.1-glibc-2.18-hard/.