From 47f4b00cb224a312fe84d23e2fa4301432321782 Mon Sep 17 00:00:00 2001 From: Christoph Pillmayer Date: Tue, 28 Oct 2025 16:21:51 +0000 Subject: [PATCH] pan: Pull out normal block logic from compute_w_entry Reviewed-by: Eric R. Smith Part-of: --- src/panfrost/compiler/bi_spill_ssa.c | 37 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/panfrost/compiler/bi_spill_ssa.c b/src/panfrost/compiler/bi_spill_ssa.c index dfad105f9f1..d393c64e331 100644 --- a/src/panfrost/compiler/bi_spill_ssa.c +++ b/src/panfrost/compiler/bi_spill_ssa.c @@ -745,25 +745,16 @@ compute_w_entry_loop_header(struct spill_ctx *ctx) } /* - * Compute W_entry for a block. Section 4.2 in the paper. + * The W_entry will contain variables that are W_exit in + * - all predecessors + * - some predecessors, sorted by next-use distance */ static ATTRIBUTE_NOINLINE void -compute_w_entry(struct spill_ctx *ctx) +compute_w_entry_usual(struct spill_ctx *ctx) { bi_block *block = ctx->block; struct spill_block *sb = spill_block(ctx, block); - /* Nothing to do for start blocks */ - if (bi_num_predecessors(block) == 0) - return; - - /* Loop headers have a different heuristic */ - if (block->loop_header) { - compute_w_entry_loop_header(ctx); - return; - } - - /* Usual blocks follow */ unsigned *freq = calloc(ctx->n_alloc, sizeof(unsigned)); /* Record what's written at the end of each predecessor */ @@ -845,6 +836,26 @@ compute_w_entry(struct spill_ctx *ctx) free(candidates); } +/* + * Compute W_entry for a block. Section 4.2 in the paper. + */ +static ATTRIBUTE_NOINLINE void +compute_w_entry(struct spill_ctx *ctx) +{ + bi_block *block = ctx->block; + + /* Nothing to do for start blocks */ + if (bi_num_predecessors(block) == 0) + return; + + /* Loop headers have a different heuristic */ + if (block->loop_header) { + compute_w_entry_loop_header(ctx); + } else { + compute_w_entry_usual(ctx); + } +} + /* * We initialize S with the union of S at the exit of (forward edge) * predecessors and the complement of W, intersected with the live-in set. The