From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23709 invoked by alias); 22 Sep 2014 14:40:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 23693 invoked by uid 89); 22 Sep 2014 14:40:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f193.google.com Received: from mail-ob0-f193.google.com (HELO mail-ob0-f193.google.com) (209.85.214.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 22 Sep 2014 14:40:44 +0000 Received: by mail-ob0-f193.google.com with SMTP id wm4so327457obc.0 for ; Mon, 22 Sep 2014 07:40:42 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.74.193 with SMTP id w1mr20568485oev.9.1411396842663; Mon, 22 Sep 2014 07:40:42 -0700 (PDT) Received: by 10.60.125.98 with HTTP; Mon, 22 Sep 2014 07:40:42 -0700 (PDT) Date: Mon, 22 Sep 2014 14:40:00 -0000 Message-ID: Subject: [PATCH IRA] update_equiv_regs fails to set EQUIV reg-note for pseudo with more than one definition From: Felix Yang To: GCC Patches , vmakarov@redhat.com Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2014-09/txt/msg01819.txt.bz2 Hi, I find that update_equiv_regs in ira.c sets the wrong EQUIV reg-note for pseudo with more than one definiton in certain situation. Here is a simplified RTL snippet after this function finishs handling: (insn 77 37 78 2 (set (reg:SI 171) (const_int 0 [0])) ticket151.c:33 52 {movsi_internal_dsp} (expr_list:REG_EQUAL (const_int 0 [0]) (nil))) ...... (insn 79 50 53 2 (set (mem/c:SI (reg/f:SI 136) [2 g_728+0 S4 A64]) (reg:SI 171)) ticket151.c:33 52 {movsi_internal_dsp} (expr_list:REG_DEAD (reg:SI 171) (nil))) (insn 53 79 54 2 (set (mem/c:SI (reg/f:SI 162) [4 g_163+0 S4 A32]) (reg:SI 163)) 52 {movsi_internal_dsp} (expr_list:REG_DEAD (reg:SI 163) (expr_list:REG_DEAD (reg/f:SI 162) (nil)))) (insn 54 53 14 2 (set (reg:SI 171) (mem/u/c:SI (symbol_ref/u:SI ("*.LC8") [flags 0x2]) [4 S4 A32])) ticket151.c:49 52 {movsi_internal_dsp} (expr_list:REG_EQUIV (mem/u/c:SI (symbol_ref/u:SI ("*.LC8") [flags 0x2]) [4 S4 A32]) (expr_list:REG_EQUAL (mem/u/c:SI (symbol_ref/u:SI ("*.LC8") [flags 0x2]) [4 S4 A32]) (nil)))) The REG_EQUIV of insn 54 is not correct as pseudo 171 is defined in insn 77 with a differerent value. This may causes reload replacing pseudo 171 with mem/u/c:SI (symbol_ref/u:SI ("*.LC8"), which is wrong. A proposed patch for this issue, please comment: Index: gcc/ira.c =================================================================== --- gcc/ira.c (revision 215460) +++ gcc/ira.c (working copy) @@ -3477,18 +3477,26 @@ update_equiv_regs (void) no_equiv (dest, set, NULL); continue; } + /* Record this insn as initializing this register. */ reg_equiv[regno].init_insns = gen_rtx_INSN_LIST (VOIDmode, insn, reg_equiv[regno].init_insns); /* If this register is known to be equal to a constant, record that it is always equivalent to the constant. */ - if (DF_REG_DEF_COUNT (regno) == 1 - && note && ! rtx_varies_p (XEXP (note, 0), 0)) + if (note && ! rtx_varies_p (XEXP (note, 0), 0)) { - rtx note_value = XEXP (note, 0); - remove_note (insn, note); - set_unique_reg_note (insn, REG_EQUIV, note_value); + if (DF_REG_DEF_COUNT (regno) == 1) + { + rtx note_value = XEXP (note, 0); + remove_note (insn, note); + set_unique_reg_note (insn, REG_EQUIV, note_value); + } + else + { + no_equiv (dest, set, NULL); + continue; + } } /* If this insn introduces a "constant" register, decrease the priority Cheers, Felix