This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Another small improvement to ira_reassign_pseudos
- From: Jeff Law <law at redhat dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 19 Apr 2010 12:21:29 -0600
- Subject: Another small improvement to ira_reassign_pseudos
While working on reload-v2 I stumbled across a second issue with
ira_reassign_pseudos which can occasionally lead to code pessimization.
Specifically, ALLOCNO_TOTAL_CONFLICT_HARD_REGS accumulated from
pseudo_forbidden_regs, which is wrong until the main reload loop
terminates.
pseudo_forbidden_regs[pseudo] is the set of hard regs that are used as
spills over the lifetime of the given pseudo. If the main reload loop
iterates more than once, the set of spills over the lifetime of a given
pseudo may change. ie, on pass 1 we might be using r0 as a spill over a
particular set of insns; however, on pass 2 we might select a different
hard register for spills over that same span of insns, say r5.
Unfortunately, r0 will have accumulated into TOTAL_CONFLICT_HARD_REGS
thus preventing r0 from being used during reallocation.
It's relatively rare for this accumulation to impact the final code with
the mainline sources, but some changes I have pending make GCC more
sensitive to the incorrect accumulation in TOTAL_CONFLICT_HARD_REGS.
Vlad created this trivial patch to resolve the situation, which I have
been successfully using for several months. I've bootstrapped &
regression tested this on the mainline.
I'm approving the patch and installing it for Vlad.
2009-11-10 Vladimir Makarov <vmakarov@redhat.com>
* ira-color.c (allocno_reload_assign): Avoid accumulating
reload registers in ALLOCNO_TOTAL_CONFLICT_HARD_REGS.
Index: ira-color.c
===================================================================
*** ira-color.c (revision 158501)
--- ira-color.c (working copy)
*************** allocno_reload_assign (ira_allocno_t a,
*** 2786,2792 ****
--- 2786,2794 ----
int hard_regno;
enum reg_class cover_class;
int regno = ALLOCNO_REGNO (a);
+ HARD_REG_SET saved;
+ COPY_HARD_REG_SET (saved, ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a));
IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), forbidden_regs);
if (! flag_caller_saves && ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
IOR_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), call_used_reg_set);
*************** allocno_reload_assign (ira_allocno_t a,
*** 2830,2836 ****
}
else if (internal_flag_ira_verbose > 3 && ira_dump_file != NULL)
fprintf (ira_dump_file, "\n");
!
return reg_renumber[regno] >= 0;
}
--- 2832,2838 ----
}
else if (internal_flag_ira_verbose > 3 && ira_dump_file != NULL)
fprintf (ira_dump_file, "\n");
! COPY_HARD_REG_SET (ALLOCNO_TOTAL_CONFLICT_HARD_REGS (a), saved);
return reg_renumber[regno] >= 0;
}