ir3: move liveness recalculation inside ir3_ra_shared
Similar to how ir3_spill does it. This will make it easier to optimize
this in the future. E.g., we only need to recalculate liveness when any
instruction were added.
Fixes: fa22b0901a ("ir3/ra: Add specialized shared register RA/spilling")
Signed-off-by: Job Noorman <jnoorman@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29497>
This commit is contained in:
@@ -2623,13 +2623,7 @@ ir3_ra(struct ir3_shader_variant *v)
|
||||
if (max_pressure.shared + max_pressure.shared_half > limit_pressure.shared ||
|
||||
(max_pressure.shared_half > 0 && max_pressure.shared > limit_pressure.shared_half) ||
|
||||
has_shared_vectors) {
|
||||
ir3_ra_shared(v, live);
|
||||
|
||||
/* Recalculate liveness and register pressure now that additional values
|
||||
* have been added.
|
||||
*/
|
||||
ralloc_free(live);
|
||||
live = ir3_calc_liveness(ctx, v->ir);
|
||||
ir3_ra_shared(v, &live);
|
||||
ir3_calc_pressure(v, live, &max_pressure);
|
||||
|
||||
ir3_debug_print(v->ir, "AFTER: shared register allocation");
|
||||
|
||||
@@ -191,7 +191,7 @@ bool ir3_spill(struct ir3 *ir, struct ir3_shader_variant *v,
|
||||
|
||||
bool ir3_lower_spill(struct ir3 *ir);
|
||||
|
||||
void ir3_ra_shared(struct ir3_shader_variant *v, struct ir3_liveness *live);
|
||||
void ir3_ra_shared(struct ir3_shader_variant *v, struct ir3_liveness **live);
|
||||
|
||||
void ir3_ra_validate(struct ir3_shader_variant *v, unsigned full_size,
|
||||
unsigned half_size, unsigned block_count, bool shared_ra);
|
||||
|
||||
@@ -1394,9 +1394,10 @@ finalize(struct ir3 *ir)
|
||||
}
|
||||
|
||||
void
|
||||
ir3_ra_shared(struct ir3_shader_variant *v, struct ir3_liveness *live)
|
||||
ir3_ra_shared(struct ir3_shader_variant *v, struct ir3_liveness **live_ptr)
|
||||
{
|
||||
struct ra_ctx ctx;
|
||||
struct ir3_liveness *live = *live_ptr;
|
||||
|
||||
ra_ctx_init(&ctx);
|
||||
ctx.intervals = rzalloc_array(NULL, struct ra_interval,
|
||||
@@ -1424,5 +1425,13 @@ ir3_ra_shared(struct ir3_shader_variant *v, struct ir3_liveness *live)
|
||||
|
||||
ir3_ra_validate(v, RA_FULL_SIZE, RA_HALF_SIZE, live->block_count, true);
|
||||
finalize(v->ir);
|
||||
|
||||
/* Recalculate liveness and register pressure now that additional values have
|
||||
* been added.
|
||||
* TODO we should only do this if any values have been spilled/reloaded.
|
||||
*/
|
||||
void *live_mem_ctx = ralloc_parent(live);
|
||||
ralloc_free(live);
|
||||
*live_ptr = ir3_calc_liveness(live_mem_ctx, v->ir);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user