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