diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c index a30455ea277..46fd8d3afdb 100644 --- a/src/freedreno/ir3/ir3_ra.c +++ b/src/freedreno/ir3/ir3_ra.c @@ -551,6 +551,18 @@ ra_file_mark_killed(struct ra_file *file, struct ra_interval *interval) interval->is_killed = true; } +static void +ra_file_unmark_killed(struct ra_file *file, struct ra_interval *interval) +{ + assert(!interval->interval.parent); + + for (physreg_t i = interval->physreg_start; i < interval->physreg_end; i++) { + BITSET_CLEAR(file->available, i); + } + + interval->is_killed = false; +} + static physreg_t ra_interval_get_physreg(const struct ra_interval *interval) { @@ -1314,15 +1326,11 @@ handle_collect(struct ra_ctx *ctx, struct ir3_instruction *instr) */ physreg_t dst_fixed = (physreg_t)~0u; - for (unsigned i = 0; i < instr->srcs_count; i++) { - if (!ra_reg_is_src(instr->srcs[i])) - continue; - - if (instr->srcs[i]->flags & IR3_REG_FIRST_KILL) { - mark_src_killed(ctx, instr->srcs[i]); + ra_foreach_src (src, instr) { + if (src->flags & IR3_REG_FIRST_KILL) { + mark_src_killed(ctx, src); } - struct ir3_register *src = instr->srcs[i]; struct ra_interval *interval = &ctx->intervals[src->def->name]; if (src->def->merge_set != dst_set || interval->is_killed) @@ -1350,11 +1358,7 @@ handle_collect(struct ra_ctx *ctx, struct ir3_instruction *instr) allocate_dst(ctx, instr->dsts[0]); /* Remove the temporary is_killed we added */ - for (unsigned i = 0; i < instr->srcs_count; i++) { - if (!ra_reg_is_src(instr->srcs[i])) - continue; - - struct ir3_register *src = instr->srcs[i]; + ra_foreach_src (src, instr) { struct ra_interval *interval = &ctx->intervals[src->def->name]; while (interval->interval.parent != NULL) { interval = ir3_reg_interval_to_ra_interval(interval->interval.parent); @@ -1362,8 +1366,9 @@ handle_collect(struct ra_ctx *ctx, struct ir3_instruction *instr) /* Filter out cases where it actually should be killed */ if (interval != &ctx->intervals[src->def->name] || - !(src->flags & IR3_REG_KILL)) - interval->is_killed = false; + !(src->flags & IR3_REG_KILL)) { + ra_file_unmark_killed(ra_get_file(ctx, src), interval); + } } ra_foreach_src_rev (src, instr) {