* [ira] patch for choosing better hard register
@ 2007-09-20 21:36 Vladimir Makarov
0 siblings, 0 replies; only message in thread
From: Vladimir Makarov @ 2007-09-20 21:36 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 497 bytes --]
The patch makes code a bit smaller by trying to assign a hard register first to allocno whose preferable register class is smaller.
2007-09-20 Vladimir Makarov <vmakarov@redhat.com>
* ira-build.c (create_allocno): Initialize ALLOCNO_BEST_CLASS.
* ira-color.c (add_allocno_to_ordered_bucket): Use
ALLOCNO_BEST_CLASS.
* ira-costs.c (setup_allocno_cover_class_and_costs): Initialize
ALLOCNO_BEST_CLASS.
* ira-int.h (allocno): New member best_class.
(ALLOCNO_BEST_CLASS): New macro.
[-- Attachment #2: ira-best-class.patch --]
[-- Type: text/x-patch, Size: 3824 bytes --]
Index: ira-build.c
===================================================================
--- ira-build.c (revision 128621)
+++ ira-build.c (working copy)
@@ -389,6 +389,7 @@ create_allocno (int regno, int cap_p, st
ALLOCNO_CURR_CONFLICT_HARD_REG_COSTS (a) = NULL;
ALLOCNO_LEFT_CONFLICTS_NUM (a) = -1;
ALLOCNO_COVER_CLASS (a) = NO_REGS;
+ ALLOCNO_BEST_CLASS (a) = NO_REGS;
ALLOCNO_COVER_CLASS_COST (a) = 0;
ALLOCNO_MEMORY_COST (a) = 0;
ALLOCNO_NEXT_BUCKET_ALLOCNO (a) = NULL;
@@ -491,6 +492,7 @@ create_cap_allocno (allocno_t a)
/* We just need to set a mode giving the same size. */
ALLOCNO_MODE (cap) = ALLOCNO_MODE (a);
ALLOCNO_COVER_CLASS (cap) = ALLOCNO_COVER_CLASS (a);
+ ALLOCNO_BEST_CLASS (cap) = ALLOCNO_BEST_CLASS (a);
ALLOCNO_AVAILABLE_REGS_NUM (cap) = ALLOCNO_AVAILABLE_REGS_NUM (a);
ALLOCNO_CAP_MEMBER (cap) = a;
hard_regs_num = class_hard_regs_num [ALLOCNO_COVER_CLASS (a)];
Index: ira-color.c
===================================================================
--- ira-color.c (revision 128621)
+++ ira-color.c (working copy)
@@ -339,17 +339,28 @@ static void
add_allocno_to_ordered_bucket (allocno_t allocno, allocno_t *bucket_ptr)
{
allocno_t before, after;
- enum reg_class cover_class;
- int freq, nregs;
+ enum reg_class cover_class, best_class, best_class_before;
+ int freq, freq_before, nregs;
- freq = ALLOCNO_FREQ (allocno);
cover_class = ALLOCNO_COVER_CLASS (allocno);
nregs = reg_class_nregs [cover_class] [ALLOCNO_MODE (allocno)];
+ freq = ALLOCNO_FREQ (allocno);
+ best_class = ALLOCNO_BEST_CLASS (allocno);
for (before = *bucket_ptr, after = NULL;
before != NULL;
after = before, before = ALLOCNO_NEXT_BUCKET_ALLOCNO (before))
- if (ALLOCNO_FREQ (before) > freq)
- break;
+ {
+ best_class_before = ALLOCNO_BEST_CLASS (before);
+ freq_before = ALLOCNO_FREQ (before);
+ if (best_class != best_class_before
+ && class_subset_p [best_class_before] [best_class])
+ break;
+ else if (best_class != best_class_before
+ && class_subset_p [best_class] [best_class_before])
+ ;
+ else if (freq_before > freq)
+ break;
+ }
ALLOCNO_NEXT_BUCKET_ALLOCNO (allocno) = before;
ALLOCNO_PREV_BUCKET_ALLOCNO (allocno) = after;
if (after == NULL)
Index: ira-costs.c
===================================================================
--- ira-costs.c (revision 128621)
+++ ira-costs.c (working copy)
@@ -1346,6 +1346,7 @@ setup_allocno_cover_class_and_costs (voi
ALLOCNO_ORIGINAL_MEMORY_COST (p)
= ALLOCNO_MEMORY_COST (p) = costs [i].mem_cost;
ALLOCNO_COVER_CLASS (p) = cover_class;
+ ALLOCNO_BEST_CLASS (p) = allocno_pref [i];
if (cover_class == NO_REGS)
continue;
ALLOCNO_AVAILABLE_REGS_NUM (p) = available_class_regs [cover_class];
Index: ira-int.h
===================================================================
--- ira-int.h (revision 128621)
+++ ira-int.h (working copy)
@@ -222,6 +222,9 @@ struct allocno
/* Register class which should be used for allocation for given
allocno. NO_REGS means that we should use memory. */
enum reg_class cover_class;
+ /* The biggest register class with minimal cost usage for given
+ allocno. */
+ enum reg_class best_class;
/* Minimal cost of usage register of the cover class and memory for
the allocno. */
int cover_class_cost, memory_cost, original_memory_cost;
@@ -269,6 +272,7 @@ struct allocno
#define ALLOCNO_CURR_CONFLICT_HARD_REG_COSTS(P) \
((P)->curr_conflict_hard_reg_costs)
#define ALLOCNO_LEFT_CONFLICTS_NUM(P) ((P)->left_conflicts_num)
+#define ALLOCNO_BEST_CLASS(P) ((P)->best_class)
#define ALLOCNO_COVER_CLASS(P) ((P)->cover_class)
#define ALLOCNO_COVER_CLASS_COST(P) ((P)->cover_class_cost)
#define ALLOCNO_MEMORY_COST(P) ((P)->memory_cost)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-09-20 20:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-20 21:36 [ira] patch for choosing better hard register Vladimir Makarov
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).