The following patch fixes gcc.gnu.org/bugzilla/show_bug.cgi?id=55456
The patch was successfully bootstrapped and tested on x86/x86-64. Committed as rev. 193948. 2012-11-28 Vladimir Makarov <vmaka...@redhat.com> PR middle-end/55456 * lra-int.h (lra_new_regno_start): New external. * lra.c (lra_new_regno_start): New global. (lra): Set up lra_new_regno_start. * lra-constraints.c (match_reload): Sync values only for original pseudos.
Index: lra.c =================================================================== --- lra.c (revision 193901) +++ lra.c (working copy) @@ -2151,6 +2151,9 @@ update_inc_notes (void) /* Set to 1 while in lra. */ int lra_in_progress; +/* Start of pseudo regnos before the LRA. */ +int lra_new_regno_start; + /* Start of reload pseudo regnos before the new spill pass. */ int lra_constraint_new_regno_start; @@ -2235,7 +2238,7 @@ lra (FILE *f) so set up lra_constraint_new_regno_start before its call to permit changing reg classes for pseudos created by this simplification. */ - lra_constraint_new_regno_start = max_reg_num (); + lra_constraint_new_regno_start = lra_new_regno_start = max_reg_num (); remove_scratches (); scratch_p = lra_constraint_new_regno_start != max_reg_num (); Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 193901) +++ lra-constraints.c (working copy) @@ -685,8 +685,10 @@ match_reload (signed char out, signed ch else new_out_reg = gen_rtx_SUBREG (outmode, reg, 0); /* If the input reg is dying here, we can use the same hard - register for REG and IN_RTX. */ - if (REG_P (in_rtx) + register for REG and IN_RTX. We do it only for original + pseudos as reload pseudos can die although original + pseudos still live where reload pseudos dies. */ + if (REG_P (in_rtx) && (int) REGNO (in_rtx) < lra_new_regno_start && find_regno_note (curr_insn, REG_DEAD, REGNO (in_rtx))) lra_reg_info[REGNO (reg)].val = lra_reg_info[REGNO (in_rtx)].val; } @@ -712,7 +714,9 @@ match_reload (signed char out, signed ch /* If SUBREG_REG is dying here and sub-registers IN_RTX and NEW_IN_REG are similar, we can use the same hard register for REG and SUBREG_REG. */ - if (REG_P (subreg_reg) && GET_MODE (subreg_reg) == outmode + if (REG_P (subreg_reg) + && (int) REGNO (subreg_reg) < lra_new_regno_start + && GET_MODE (subreg_reg) == outmode && SUBREG_BYTE (in_rtx) == SUBREG_BYTE (new_in_reg) && find_regno_note (curr_insn, REG_DEAD, REGNO (subreg_reg))) lra_reg_info[REGNO (reg)].val Index: lra-int.h =================================================================== --- lra-int.h (revision 193901) +++ lra-int.h (working copy) @@ -295,6 +295,7 @@ extern lra_copy_t lra_get_copy (int); extern bool lra_former_scratch_p (int); extern bool lra_former_scratch_operand_p (rtx, int); +extern int lra_new_regno_start; extern int lra_constraint_new_regno_start; extern bitmap_head lra_inheritance_pseudos; extern bitmap_head lra_split_regs;