From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5675 invoked by alias); 31 Dec 2014 16:33:28 -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 5650 invoked by uid 48); 31 Dec 2014 16:33:23 -0000 From: "thopre01 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/64458] New: [ARM] Redundant ldr when accessing var inside and outside a loop Date: Wed, 31 Dec 2014 16:33:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: thopre01 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-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cf_gcctarget 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-12/txt/msg03003.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64458 Bug ID: 64458 Summary: [ARM] Redundant ldr when accessing var inside and outside a loop Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: thopre01 at gcc dot gnu.org Target: arm-none-eabi When compiling the below example with -O2, 2 ldr are generated to access the variable "some": one for the loop and one for the store. int f (int); unsigned int glob; void g (void) { while (glob); glob = 1; } The following code is then generated: 0: push {r4, lr} 4: ldr r4, pc, #32 ; 2c 8: ldr r0, [r4] c: bl 0 10: cmp r0, #0 14: ldr r3, pc, #16 ; 2c 18: bne 8 1c: mov r2, #1 20: pop {r4, lr} 24: str r2, [r3] 28: bx lr 2c: .word 0x00000000 Note the redundant load of the address at offset 2c in instructions at offsets 4 and 14.