From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26598 invoked by alias); 2 Jan 2010 14:08:43 -0000 Received: (qmail 26570 invoked by uid 48); 2 Jan 2010 14:08:32 -0000 Date: Sat, 02 Jan 2010 14:08:00 -0000 Message-ID: <20100102140832.26569.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/42574] [4.3/4.4/4.5 Regression] Address of global variable is calculated multiple times (missed CSE) In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "steven 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-01/txt/msg00110.txt.bz2 ------- Comment #6 from steven at gcc dot gnu dot org 2010-01-02 14:08 ------- Created an attachment (id=19446) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19446&action=view) Classic GCSE, resurrected (with some improvements) With this patch (not bootstrapped/tested/etc.), I get the following code: test: push {r4, r5, r6, lr} ldr r3, .L4 ldr r2, .L4+4 .LPIC0: add r3, pc ldr r5, [r3, r2] mov r4, #200 lsl r4, r4, #1 mov r6, r0 ldr r0, [r5, r4] bl func1 ldr r0, [r5, r4] mov r1, r6 bl func2 cmp r0, #0 beq .L2 bl func .L2: mov r3, #200 lsl r3, r3, #1 ldr r0, [r5, r3] bl func3 @ sp needed for prologue pop {r4, r5, r6, pc} The constant load of #400 is not eliminated, because classic GCSE is not value numbering, so to it, the following expressions in insns 11 and 31 are not equivalent: 11 r141:SI=0x190 12 r142:SI=[r139:SI+r141:SI] REG_EQUAL: [const(`glob'+0x190)] 30 r149:SI=0x190 31 r150:SI=[r139:SI+r149:SI] The REG_EQUAL note is probably not exploited because it is a CONST and want_to_gcse_p rejects it (someone should check if that is indeed the reason). I have no intention at this point to finish this patch. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42574