diff options
author | Eric Anholt <[email protected]> | 2015-10-23 21:46:40 +0100 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2017-07-25 14:44:52 -0700 |
commit | 30146f29a723a3a3abe7cf7ef6cc8567880a077d (patch) | |
tree | 8346c0cfb1f846b038b18e242015d315eb442aa7 /src/util/register_allocate.c | |
parent | 16e17ce04b60ac6f3d9a89535ea583fabebead7a (diff) |
ra: Pull the body of a loop out to a helper function.
I was going to indent this code another level, and decided it would be
easier to read as a helper.
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/util/register_allocate.c')
-rw-r--r-- | src/util/register_allocate.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c index 8af93c0406c..35ef9a714cc 100644 --- a/src/util/register_allocate.c +++ b/src/util/register_allocate.c @@ -539,6 +539,23 @@ ra_simplify(struct ra_graph *g) g->stack_optimistic_start = stack_optimistic_start; } +static bool +ra_any_neighbors_conflict(struct ra_graph *g, unsigned int n, unsigned int r) +{ + unsigned int i; + + for (i = 0; i < g->nodes[n].adjacency_count; i++) { + unsigned int n2 = g->nodes[n].adjacency_list[i]; + + if (!g->nodes[n2].in_stack && + BITSET_TEST(g->regs->regs[r].conflicts, g->nodes[n2].reg)) { + return true; + } + } + + return false; +} + /** * Pops nodes from the stack back into the graph, coloring them with * registers as they go. @@ -552,7 +569,6 @@ ra_select(struct ra_graph *g) int start_search_reg = 0; while (g->stack_count != 0) { - unsigned int i; unsigned int ri; unsigned int r = -1; int n = g->stack[g->stack_count - 1]; @@ -566,17 +582,8 @@ ra_select(struct ra_graph *g) if (!reg_belongs_to_class(r, c)) continue; - /* Check if any of our neighbors conflict with this register choice. */ - for (i = 0; i < g->nodes[n].adjacency_count; i++) { - unsigned int n2 = g->nodes[n].adjacency_list[i]; - - if (!g->nodes[n2].in_stack && - BITSET_TEST(g->regs->regs[r].conflicts, g->nodes[n2].reg)) { - break; - } - } - if (i == g->nodes[n].adjacency_count) - break; + if (!ra_any_neighbors_conflict(g, n, r)) + break; } /* set this to false even if we return here so that |