From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23285 invoked by alias); 23 Mar 2010 14:21:57 -0000 Received: (qmail 23236 invoked by uid 48); 23 Mar 2010 14:21:44 -0000 Date: Tue, 23 Mar 2010 14:21:00 -0000 Subject: [Bug rtl-optimization/43491] New: Unnecessary temporary for global register variable X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mirq-gccboogs at rere dot qmqm dot pl" 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-03/txt/msg02319.txt.bz2 gcc sometimes allocates a temporary register for a variable that is global and has a fixed register. This happens when: a. the global is a register-fixed variable b. global is a pointer to structure c. an address of structure's field is passed as argument to inlined function d. the global is marked as constant code: struct b { unsigned g,h,j; }; register struct b *const reg asm("r4"); static inline int diff(unsigned *p) { return *p; } void c(void); void d(void) { while (diff(®->j)) c(); } generates: d: @ args = 0, pretend = 0, frame = 0 @ frame_needed = 0, uses_anonymous_args = 0 ldr r3, [r4, #8] @ first ok push {r5, lr} mov r5, r4 @ an temporary even when r4 is marked const cbz r3, .L1 .L4: bl c ldr r3, [r5, #8] @ accesses via temporary cmp r3, #0 bne .L4 .L1: pop {r5, pc} -- Summary: Unnecessary temporary for global register variable Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mirq-gccboogs at rere dot qmqm dot pl GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: arm-none-eabi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43491