pan/midgard: Move bounds checking into LCRA
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 6 Dec 2019 16:38:10 +0000 (11:38 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 12 Dec 2019 16:42:06 +0000 (11:42 -0500)
This simplifies the cost calculation code a bit.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/lcra.c
src/panfrost/midgard/midgard_ra.c

index 7c0a3a96bab6a1d8d6ead0e89253e04ccccbf284..c6411b8c3797da9922aa4d9130ea0e841ed2dac9 100644 (file)
@@ -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 */
index 2e00aefb3852a3164b1cf19207eee8a9b99deb33..2c8965b79167420bd631e6a46175a2fcd47031ca 100644 (file)
@@ -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);
                 }
         }