From 3add6b10a824642c8eaaf9a50fb8fa52a7557166 Mon Sep 17 00:00:00 2001 From: Radu Costas Date: Wed, 27 May 2026 11:14:59 +0300 Subject: [PATCH] pco: Move preproc_vecs out of loop To avoid extra unnecessary calls of the function when temp spilling happens multiple times within a shader func Signed-off-by: Radu Costas Reviewed-by: Simon Perretta Part-of: --- src/imagination/pco/pco_ra.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/imagination/pco/pco_ra.c b/src/imagination/pco/pco_ra.c index b23d970f5b3..291c0dac97e 100644 --- a/src/imagination/pco/pco_ra.c +++ b/src/imagination/pco/pco_ra.c @@ -117,8 +117,9 @@ typedef struct _pco_use { pco_ref *ref; } pco_use; -static void preproc_vecs(pco_func *func) +static bool preproc_vecs(pco_func *func) { + bool progress = false; unsigned num_ssas = func->next_ssa; void *mem_ctx = ralloc_context(NULL); @@ -214,6 +215,7 @@ static void preproc_vecs(pco_func *func) pco_instr_delete(use->instr); needs_reindex = true; } + progress = true; } } @@ -221,6 +223,8 @@ static void preproc_vecs(pco_func *func) if (needs_reindex) pco_index(func->parent_shader, false); + + return progress; } typedef struct _pco_copy { @@ -445,9 +449,7 @@ static void spill(unsigned spill_index, pco_func *func, pco_ra_ctx *ctx) * \brief Performs register allocation on a function. * * \param[in,out] func PCO shader. - * \param[in] allocable_temps Number of allocatable temp registers. - * \param[in] allocable_vtxins Number of allocatable vertex input registers. - * \param[in] allocable_interns Number of allocatable internal registers. + * \param[in,out] ctx Register allocation context. * \return True if registers were allocated. */ static bool pco_ra_func(pco_func *func, pco_ra_ctx *ctx) @@ -459,8 +461,6 @@ static bool pco_ra_func(pco_func *func, pco_ra_ctx *ctx) * TODO: track successors/predecessors. */ - preproc_vecs(func); - unsigned num_rsvd_vtxins = func->parent_shader->data.common.vtxins; unsigned num_ssas = func->next_ssa; unsigned num_vregs = func->next_vreg; @@ -1173,6 +1173,7 @@ bool pco_ra(pco_shader *shader) bool progress = false; pco_foreach_func_in_shader (func, shader) { ctx.done = false; + progress |= preproc_vecs(func); while (!ctx.done) progress |= pco_ra_func(func, &ctx);