From 3c0f1ea58c963194baa547f588155b00d5768bd6 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 6 Dec 2019 11:38:10 -0500 Subject: [PATCH] pan/midgard: Move bounds checking into LCRA This simplifies the cost calculation code a bit. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/lcra.c | 3 ++- src/panfrost/midgard/midgard_ra.c | 11 +++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/panfrost/midgard/lcra.c b/src/panfrost/midgard/lcra.c index 7c0a3a96bab..c6411b8c379 100644 --- a/src/panfrost/midgard/lcra.c +++ b/src/panfrost/midgard/lcra.c @@ -197,7 +197,8 @@ lcra_solve(struct lcra_state *l) void lcra_set_node_spill_cost(struct lcra_state *l, unsigned node, signed cost) { - l->spill_cost[node] = cost; + if (node < l->node_count) + l->spill_cost[node] = cost; } /* Count along the lower triangle */ diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index 2e00aefb385..2c8965b7916 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -689,15 +689,10 @@ mir_choose_spill_node( mir_foreach_instr_global(ctx, ins) { if (ins->no_spill) { - if (ins->dest < ctx->temp_count) - lcra_set_node_spill_cost(l, ins->dest, -1); + lcra_set_node_spill_cost(l, ins->dest, -1); - mir_foreach_src(ins, s) { - unsigned src = ins->src[s]; - - if (src < ctx->temp_count) - lcra_set_node_spill_cost(l, src, -1); - } + mir_foreach_src(ins, s) + lcra_set_node_spill_cost(l, ins->src[s], -1); } } -- 2.30.2