[Mesa-dev] [PATCH v2 3/4] ra: consider all spillable nodes for spilling
Connor Abbott
cwabbott0 at gmail.com
Wed Jul 30 22:34:40 PDT 2014
Before, we would only consider nodes for spilling if they were
optimistically pushed onto the stack. But the logic for this was
complicated, and duplicated some things; also, we might want to spill
nodes that are not optimistically colored if our heuristic says we
should. This becomes a problem especially after the next commit, where
duplicating the current behavior of only spilling optimistically colored
nodes can sometimes leave the backend in a position where it has no
registers to spill. So just drop the original logic, and consider
everything that has its spill cost set for spilling.
HURT: shaders/steam/dungeon-defenders/5008.shader_test SIMD8: 434 -> 439 (1.15%)
total instructions in shared programs: 4547617 -> 4547622 (0.00%)
instructions in affected programs: 434 -> 439 (1.15%)
GAINED: 0
LOST: 0
Signed-off-by: Connor Abbott <connor.abbott at intel.com>
---
src/mesa/program/register_allocate.c | 52 +++++-------------------------------
1 file changed, 6 insertions(+), 46 deletions(-)
diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index 73d3b1a..f2f5910 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -168,16 +168,6 @@ struct ra_graph {
unsigned int *stack;
unsigned int stack_count;
-
- /**
- * Tracks the start of the set of optimistically-colored registers in the
- * stack.
- *
- * Along with any registers not in the stack (if one called ra_simplify()
- * and didn't do optimistic coloring), these need to be considered for
- * spilling.
- */
- unsigned int stack_optimistic_start;
};
/**
@@ -554,7 +544,6 @@ ra_optimistic_color(struct ra_graph *g)
{
unsigned int i;
- g->stack_optimistic_start = g->stack_count;
for (i = 0; i < g->count; i++) {
if (g->nodes[i].in_stack || g->nodes[i].reg != NO_REG)
continue;
@@ -633,51 +622,22 @@ ra_get_best_spill_node(struct ra_graph *g)
{
unsigned int best_node = -1;
float best_benefit = 0.0;
- unsigned int n, i;
-
- /* For any registers not in the stack to be colored, consider them for
- * spilling. This will mostly collect nodes that were being optimistally
- * colored as part of ra_allocate() if we didn't successfully
- * optimistically color.
- *
- * It also includes nodes not trivially colorable by ra_simplify() if it
- * was used directly instead of as part of ra_allocate().
- */
- for (n = 0; n < g->count; n++) {
- float cost = g->nodes[n].spill_cost;
- float benefit;
-
- if (cost <= 0.0)
- continue;
-
- if (g->nodes[n].in_stack)
- continue;
-
- benefit = ra_get_spill_benefit(g, n);
-
- if (benefit / cost > best_benefit) {
- best_benefit = benefit / cost;
- best_node = n;
- }
- }
+ unsigned int i;
- /* Also consider spilling any nodes that were set up to be optimistically
- * colored that we couldn't manage to color in ra_select().
- */
- for (i = g->stack_optimistic_start; i < g->stack_count; i++) {
+ /* Consider spilling any nodes with a spill cost set */
+ for (i = 0; i < g->count; i++) {
float cost, benefit;
- n = g->stack[i];
- cost = g->nodes[n].spill_cost;
+ cost = g->nodes[i].spill_cost;
if (cost <= 0.0)
continue;
- benefit = ra_get_spill_benefit(g, n);
+ benefit = ra_get_spill_benefit(g, i);
if (benefit / cost > best_benefit) {
best_benefit = benefit / cost;
- best_node = n;
+ best_node = i;
}
}
--
1.9.3
More information about the mesa-dev
mailing list