public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH IRA] update_equiv_regs fails to set EQUIV reg-note for pseudo with more than one definition
@ 2014-09-22 14:40 Felix Yang
  2014-09-22 18:40 ` Jeff Law
  0 siblings, 1 reply; 27+ messages in thread
From: Felix Yang @ 2014-09-22 14:40 UTC (permalink / raw)
  To: GCC Patches, vmakarov

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2015-02-13 23:18 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-22 14:40 [PATCH IRA] update_equiv_regs fails to set EQUIV reg-note for pseudo with more than one definition Felix Yang
2014-09-22 18:40 ` Jeff Law
2014-09-23  2:48   ` Yangfei (Felix)
2014-09-23 10:46     ` Felix Yang
2014-09-23 10:51       ` Felix Yang
2014-09-23 17:49         ` Jeff Law
2014-09-24 12:07           ` Felix Yang
2014-09-24 21:56             ` Felix Yang
2014-09-25  4:07               ` [PING PATCH " Yangfei (Felix)
2014-09-25 18:57             ` [PATCH " Jeff Law
2014-09-26 13:57               ` Felix Yang
2014-09-26 21:03                 ` Jeff Law
2014-09-27 14:48                   ` Felix Yang
2014-09-29 21:44                     ` Jeff Law
2014-10-11 13:13                       ` Felix Yang
2014-10-13 20:30                         ` Jeff Law
2015-02-02 15:59                         ` Alex Velenko
2015-02-03  7:24                           ` Jeff Law
2015-02-03  8:29                             ` Bin.Cheng
2015-02-03 12:42                               ` Alex Velenko
2015-02-03 16:28                               ` Jeff Law
2015-02-04  3:03                                 ` Bin.Cheng
2015-02-09 23:32                                   ` Jeff Law
2015-02-10 10:51                                     ` Ajit Kumar Agarwal
2015-02-10 15:46                                       ` Jeff Law
2015-02-12 12:40                                     ` Alex Velenko
2015-02-13 23:18                                       ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).