From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19521 invoked by alias); 8 Jun 2010 10:41:58 -0000 Received: (qmail 19468 invoked by uid 48); 8 Jun 2010 10:41:43 -0000 Date: Tue, 08 Jun 2010 10:41:00 -0000 Message-ID: <20100608104143.19467.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/42495] redundant memory load In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mkuvyrkov at gcc dot gnu dot org" 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-06/txt/msg00870.txt.bz2 ------- Comment #5 from mkuvyrkov at gcc dot gnu dot org 2010-06-08 10:41 ------- Elimination of subsequent calculations of PIC addresses should be handled in code hoisting optimization. However, there are two problems that inhibit the optimization: 1. ARM backend outputs calculation of a PIC address as two instructions (load GOT offset from constant pool and then load PIC address from GOT) and hoist only handles expressions contained in a single_set(). 2. Hoisting algorithm misses many opportunities for expression hoisting to basic blocks that contain calculation of the expression. I.e., expr from bb4 will not be hoisted to bb2 even though it is trivially profitable: bb2: expr condjump bb4 bb3: jump bb5 bb4: expr bb5: I'm testing patches to the ARM backend and code hoisting pass which fix the above problems. The generated code calculates address of the global variable only once: goo: push {r3, r4, r5, lr} ldr r3, .L6 ldr r2, .L6+4 .LPIC0: add r3, pc ldr r5, [r3, r2] mov r4, r0 ldr r3, [r5] ldr r0, [r3] cmp r0, #0 beq .L2 mov r1, r4 bl foo .L2: ldr r3, [r4] mov r0, #0 cmp r3, #0 beq .L3 ldr r2, [r5] cmp r3, r2 beq .L3 ldr r0, [r3] .L3: @ sp needed for prologue pop {r3, r4, r5, pc} .L7: .align 2 .L6: .word _GLOBAL_OFFSET_TABLE_-(.LPIC0+4) .word gObj(GOT) -- mkuvyrkov at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |mkuvyrkov at gcc dot gnu dot |dot org |org Status|WAITING |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2010-06-08 10:41:43 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42495