freedreno/ir3/ra: remove unused variable
[mesa.git] / src / freedreno / ir3 / ir3_ra.c
index 7999bb34f7112392104954fdb76334fcef756c0f..94386ed46942979525cf0a5eed4d0b8c970f2208 100644 (file)
@@ -441,11 +441,11 @@ ra_select_reg_merged(unsigned int n, BITSET_WORD *regs, void *data)
        if (!ctx->scalar_pass) {
                base = ctx->set->gpr_to_ra_reg[class][0];
                if (high) {
-                       max_target = HIGH_CLASS_REGS(sz);
+                       max_target = HIGH_CLASS_REGS(class - HIGH_OFFSET);
                } else if (half) {
-                       max_target = HALF_CLASS_REGS(sz);
+                       max_target = HALF_CLASS_REGS(class - HALF_OFFSET);
                } else {
-                       max_target = CLASS_REGS(sz);
+                       max_target = CLASS_REGS(class);
                }
 
                if ((sz == 1) && !high) {
@@ -478,9 +478,16 @@ ra_select_reg_merged(unsigned int n, BITSET_WORD *regs, void *data)
         * for write after read hazards:
         */
        struct ir3_instruction *instr = name_to_instr(ctx, n);
-       if (is_sfu(instr) && instr->regs[1]->instr) {
-               struct ir3_instruction *src = instr->regs[1]->instr;
-               unsigned src_n = scalar_name(ctx, src, 0);
+       if (is_sfu(instr)) {
+               struct ir3_register *src = instr->regs[1];
+               int src_n;
+
+               if ((src->flags & IR3_REG_ARRAY) && !(src->flags & IR3_REG_RELATIV)) {
+                       struct ir3_array *arr = ir3_lookup_array(ctx->ir, src->array.id);
+                       src_n = arr->base + src->array.offset;
+               } else {
+                       src_n = scalar_name(ctx, src->instr, 0);
+               }
 
                unsigned reg = ra_get_node_reg(ctx->g, src_n);
 
@@ -534,7 +541,7 @@ ra_init(struct ir3_ra_ctx *ctx)
        unsigned n, base;
 
        ir3_clear_mark(ctx->ir);
-       n = ir3_count_instructions(ctx->ir);
+       n = ir3_count_instructions_ra(ctx->ir);
 
        ctx->instrd = rzalloc_array(NULL, struct ir3_ra_instr_data, n);
 
@@ -943,6 +950,15 @@ ra_calc_block_live_values(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 
        /* the remaining live should match liveout (for extra sanity testing): */
        if (RA_DEBUG) {
+               unsigned new_dead = 0;
+               BITSET_FOREACH_SET (name, live, ctx->alloc_count) {
+                       /* Is this the last use? */
+                       if (ctx->use[name] != block->end_ip)
+                               continue;
+                       new_dead += name_size(ctx, name);
+                       d("NEW_DEAD: %u (new_dead=%u)", name, new_dead);
+                       BITSET_CLEAR(live, name);
+               }
                unsigned liveout = 0;
                BITSET_FOREACH_SET (name, bd->liveout, ctx->alloc_count) {
                        liveout += name_size(ctx, name);
@@ -1258,7 +1274,6 @@ ra_block_alloc(struct ir3_ra_ctx *ctx, struct ir3_block *block)
 static void
 ra_precolor(struct ir3_ra_ctx *ctx, struct ir3_instruction **precolor, unsigned nprecolor)
 {
-       unsigned num_precolor = 0;
        for (unsigned i = 0; i < nprecolor; i++) {
                if (precolor[i] && !(precolor[i]->flags & IR3_INSTR_UNUSED)) {
                        struct ir3_instruction *instr = precolor[i];
@@ -1298,7 +1313,6 @@ ra_precolor(struct ir3_ra_ctx *ctx, struct ir3_instruction **precolor, unsigned
                        unsigned reg = ctx->set->gpr_to_ra_reg[id->cls][regid];
                        unsigned name = ra_name(ctx, id);
                        ra_set_node_reg(ctx->g, name, reg);
-                       num_precolor = MAX2(regid, num_precolor);
                }
        }