From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5315 invoked by alias); 20 Oct 2011 11:07:32 -0000 Received: (qmail 5304 invoked by uid 22791); 20 Oct 2011 11:07:30 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_CP,TW_DR 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, 20 Oct 2011 11:07:14 +0000 From: "sebastian.huber@embedded-brains.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/50106] [ARM] Wrong code with -march=armv5t -mthumb -Os Date: Thu, 20 Oct 2011 11:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: sebastian.huber@embedded-brains.de X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ramana at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.2 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: 2011-10/txt/msg02119.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50106 --- Comment #11 from Sebastian Huber 2011-10-20 11:07:09 UTC --- Thank you very much. With this change the GCC 4.6.2-RC-20111019 produces now correct code in this case. I know understand why the unused volatile registers are saved and restored. This is to get rid of the arithmetic stack adjustments. --- test.Os.GCC-4.5.s 2011-10-20 13:04:15.384638860 +0200 +++ test.Os.GCC-4.6.s 2011-10-20 13:04:15.396639237 +0200 @@ -17,32 +17,29 @@ .thumb_func .type _GetIDS, %function _GetIDS: - push {lr} - ldr r2, .L4 - sub sp, sp, #12 - ldr r2, [r2] - mov r3, r0 + push {r0, r1, r2, lr} + ldr r3, .L4 ldr r1, .L4+4 - add r0, sp, #4 - cmp r3, r2 + ldr r3, [r3] + cmp r0, r3 bge .L2 - lsl r3, r3, #1 - add r1, r1, r3 + lsl r0, r0, #1 + add r1, r1, r0 .L2: mov r2, #2 + add r0, sp, #4 bl memcpy add r3, sp, #4 ldrb r0, [r3, #1] ldrb r2, [r3] lsl r0, r0, #8 - add sp, sp, #12 - orr r0, r0, r2 + orr r0, r2 @ sp needed for prologue - pop {pc} + pop {r1, r2, r3, pc} .L5: .align 2 .L4: .word _LIST_SIZE .word _List .size _GetIDS, .-_GetIDS - .ident "GCC: (GNU) 4.5.4 20111013 (prerelease)" + .ident "GCC: (GNU) 4.6.2 20111019 (prerelease)"