From patchwork Fri Dec 17 16:13:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bingfeng Mei X-Patchwork-Id: 75920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 950FE1007D3 for ; Sat, 18 Dec 2010 03:14:04 +1100 (EST) Received: (qmail 19868 invoked by alias); 17 Dec 2010 16:13:58 -0000 Received: (qmail 19837 invoked by uid 22791); 17 Dec 2010 16:13:54 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, MIME_BASE64_BLANKS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mms1.broadcom.com (HELO mms1.broadcom.com) (216.31.210.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Dec 2010 16:13:50 +0000 Received: from [10.16.192.224] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Fri, 17 Dec 2010 08:14:28 -0800 X-Server-Uuid: 02CED230-5797-4B57-9875-D5D2FEE4708A Received: from SJEXCHCCR02.corp.ad.broadcom.com ([10.16.192.130]) by SJEXCHHUB01.corp.ad.broadcom.com ([10.16.192.224]) with mapi; Fri, 17 Dec 2010 08:13:43 -0800 From: "Bingfeng Mei" To: "Ian Lance Taylor" cc: "gcc@gcc.gnu.org" , "gcc-patches@gcc.gnu.org" Date: Fri, 17 Dec 2010 08:13:34 -0800 Subject: RE: Is eliminate_regs_in_insn allowed to generate invalid instruction? Message-ID: <7FB04A5C213E9943A72EE127DB74F0ADA692DD8CF5@SJEXCHCCR02.corp.ad.broadcom.com> References: <7FB04A5C213E9943A72EE127DB74F0ADA692DD8AFA@SJEXCHCCR02.corp.ad.broadcom.com> <7FB04A5C213E9943A72EE127DB74F0ADA692DD8BF5@SJEXCHCCR02.corp.ad.broadcom.com> In-Reply-To: x-cr-puzzleid: {76D7308D-D921-4D06-972E-971FBCD42A0F} x-cr-hashedpuzzle: BNf4 Cq8Q DCAL HQ0+ Ib/m KSHv KrRI NCMB QE8Y Q7ZJ TJz8 XzJe asc+ a+Dj biv1 c1NP; 3; ZwBjAGMALQBwAGEAdABjAGgAZQBzAEAAZwBjAGMALgBnAG4AdQAuAG8AcgBnADsAZwBjAGMAQABnAGMAYwAuAGcAbgB1AC4AbwByAGcAOwBpAGEAbgB0AEAAZwBvAG8AZwBsAGUALgBjAG8AbQA=; Sosha1_v1; 7; {76D7308D-D921-4D06-972E-971FBCD42A0F}; YgBtAGUAaQBAAGIAcgBvAGEAZABjAG8AbQAuAGMAbwBtAA==; Fri, 17 Dec 2010 16:13:34 GMT; UgBFADoAIABJAHMAIABlAGwAaQBtAGkAbgBhAHQAZQBfAHIAZQBnAHMAXwBpAG4AXwBpAG4AcwBuACAAYQBsAGwAbwB3AGUAZAAgAHQAbwAgAGcAZQBuAGUAcgBhAHQAZQAgAGkAbgB2AGEAbABpAGQAIABpAG4AcwB0AHIAdQBjAHQAaQBvAG4APwA= MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, Ian, I think I found the cause. find_reloads_address returns 0 even it reloads both parts of address (see the patch). Therefore, corresponding address_reloaded[i] is not set and in the following code of find_reloads, if (EXTRA_CONSTRAINT_STR (operand, c, p)) win = 1; /* If the address was already reloaded, we win as well. */ else if (MEM_P (operand) && address_reloaded[i] == 1) <-- address_reloaded[i] still 0 win = 1; ... Extra reload is thus generated even it is unnecessary and causes ICE. It looks like a general GCC bug. But I couldn't produce a test for x86. The following patch is bootstrapped and passes tests on x86_64-unknown-linux-gnu. Is it OK to apply the patch? Cheers, Bingfeng > -----Original Message----- > From: Ian Lance Taylor [mailto:iant@google.com] > Sent: 17 December 2010 15:10 > To: Bingfeng Mei > Cc: gcc@gcc.gnu.org > Subject: Re: Is eliminate_regs_in_insn allowed to generate invalid > instruction? > > "Bingfeng Mei" writes: > > > from gen_reload function. > > /* Otherwise, just write (set OUT IN) and hope for the best. */ > > else > > emit_insn (gen_rtx_SET (VOIDmode, out, in)); > > Those lines are one of the curses of reload. When you hit them, you > know something has gone wrong. Unfortunately, exactly what has gone > wrong can be difficult to determine. It basically means that you are > trying to reload something that the reload pass does not understand. > > > > The comment doesn’t sound very convincing to me. > > > > > > From debug message: > > Reloads for insn # 680 > > Reload 0: reload_in (SI) = (plus:SI (reg/f:SI 57 r57) > > (const_int 40 > [0x28])) > > GR_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum = 1) > > reload_in_reg: (plus:SI (reg/f:SI 57 r57) > > (const_int 40 > [0x28])) > > reload_reg_rtx: (reg:SI 4 r4) > > Reload 1: reload_in (SI) = (plus:SI (reg/f:SI 57 r57) > > (const_int 78396 > [0x1323c])) > > GR_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum = 1), can't combine > > reload_in_reg: (plus:SI (reg/f:SI 57 r57) > > (const_int 78396 > [0x1323c])) > > reload_reg_rtx: (reg:SI 6 r6) > > Reload 2: reload_in (SI) = (mem/c:SI (plus:SI (reg/f:SI 57 r57) > > (const_int > 78396 [0x1323c])) [50 %sfp+78252 S4 A32]) > > GR_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum = 1), can't combine > > reload_in_reg: (reg:SI 596 [ ivtmp.474 ]) > > reload_reg_rtx: (reg:SI 9 r9) > > Reload 3: reload_in (SI) = (plus:SI (mult:SI (reg:SI 596 > [ ivtmp.474 ]) > > (const_int 8 > [0x8])) > > (plus:SI > (reg/f:SI 57 r57) > > (const_int 40 > [0x28]))) > > GR_REGS, RELOAD_FOR_INPUT (opnum = 1), inc by 8 > > reload_in_reg: (plus:SI (mult:SI (reg:SI 596 [ ivtmp.474 ]) > > (const_int 8 > [0x8])) > > (plus:SI > (reg/f:SI 57 r57) > > (const_int 40 > [0x28]))) > > reload_reg_rtx: (reg:SI 4 r4) > > > > > > I don’t understand why Reload 3 is necessary. After reload 0, 1, 2, > > The following expression already fits into our addressing mode. > > > > (plus:SI (mult:SI (reg:SI 9 r9) (const_int 8 [0x8])) > > (reg:SI 4 r4)) > > > > Instead GCC tries to generate invalid > > (insn 1716 1715 680 84 src/weighted_prediction.c:729 (set (reg:SI 4 > r4) > > (plus:SI (mult:SI (reg:SI 9 r9) > > (const_int 8 [0x8])) > > (reg:SI 4 r4))) -1 (nil)) > > and load from [r4] subsequently. > > Sounds like you're well on the way to tracking down the problem: you > need to see why gcc decided to add reload 3 given the existence of the > reloads 0 through 2. In particular, look at the code after > if (strict_memory_address_addr_space_p (mode, ad, as)) > in find_reloads_address. > > Ian Index: reload.c =================================================================== --- reload.c (revision 167979) +++ reload.c (working copy) @@ -5188,7 +5188,7 @@ find_reloads_address (enum machine_mode &XEXP (ad, 1 - op_index), opnum, type, 0, insn); - return 0; + return 1; } }