summaryrefslogtreecommitdiff
path: root/gcc/ira-build.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-25 16:29:38 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-25 16:29:38 +0000
commit1180227da9468068505eecabef53ae074e84e13d (patch)
treeace36499c6ea271801246917f229ce0e4ae06195 /gcc/ira-build.c
parenta8c5787315d0d63a3968015beebc25e5117f2a9c (diff)
downloadgcc-1180227da9468068505eecabef53ae074e84e13d.tar.gz
* ira-build.c (update_conflict_hard_reg_costs): New.
(ira_build): Call update_conflict_hard_reg_costs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159830 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ira-build.c')
-rw-r--r--gcc/ira-build.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/gcc/ira-build.c b/gcc/ira-build.c
index c879efa9db2..3bd98f658cf 100644
--- a/gcc/ira-build.c
+++ b/gcc/ira-build.c
@@ -1,5 +1,5 @@
/* Building internal representation for IRA.
- Copyright (C) 2006, 2007, 2008, 2009
+ Copyright (C) 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Vladimir Makarov <vmakarov@redhat.com>.
@@ -2757,6 +2757,44 @@ check_allocno_creation (void)
}
#endif
+/* Identify allocnos which prefer a register class with a single hard register.
+ Adjust ALLOCNO_CONFLICT_HARD_REG_COSTS so that conflicting allocnos are
+ less likely to use the preferred singleton register. */
+static void
+update_conflict_hard_reg_costs (void)
+{
+ ira_allocno_t a;
+ ira_allocno_iterator ai;
+ int i, index, min;
+
+ FOR_EACH_ALLOCNO (a, ai)
+ {
+ enum reg_class cover_class = ALLOCNO_COVER_CLASS (a);
+ enum reg_class pref = reg_preferred_class (ALLOCNO_REGNO (a));
+
+ if (reg_class_size[pref] != 1)
+ continue;
+ index = (ira_class_hard_reg_index[cover_class]
+ [ira_class_hard_regs[pref][0]]);
+ if (index < 0)
+ continue;
+ if (ALLOCNO_CONFLICT_HARD_REG_COSTS (a) == NULL
+ || ALLOCNO_HARD_REG_COSTS (a) == NULL)
+ continue;
+ min = INT_MAX;
+ for (i = ira_class_hard_regs_num[cover_class] - 1; i >= 0; i--)
+ if (ALLOCNO_HARD_REG_COSTS (a)[i] > ALLOCNO_COVER_CLASS_COST (a)
+ && min > ALLOCNO_HARD_REG_COSTS (a)[i])
+ min = ALLOCNO_HARD_REG_COSTS (a)[i];
+ if (min == INT_MAX)
+ continue;
+ ira_allocate_and_set_costs (&ALLOCNO_CONFLICT_HARD_REG_COSTS (a),
+ cover_class, 0);
+ ALLOCNO_CONFLICT_HARD_REG_COSTS (a)[index]
+ -= min - ALLOCNO_COVER_CLASS_COST (a);
+ }
+}
+
/* Create a internal representation (IR) for IRA (allocnos, copies,
loop tree nodes). If LOOPS_P is FALSE the nodes corresponding to
the loops (except the root which corresponds the all function) and
@@ -2796,6 +2834,7 @@ ira_build (bool loops_p)
sort_conflict_id_allocno_map ();
setup_min_max_conflict_allocno_ids ();
ira_build_conflicts ();
+ update_conflict_hard_reg_costs ();
if (! ira_conflicts_p)
{
ira_allocno_t a;