From 949a4458eab131e732fe04633b83cf02c54c7b19 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 5 Nov 2025 14:02:24 -0500 Subject: [PATCH] pan/bi: Call constant folding in postprocess() The comment explicitly calls out pan_nir_lower_store_component(), which is in a different function call so it's a bit weird to have it in the caller. Also, we already do this in postprocess() on midgard so it makes more sense to just move it into bifrost. Reviewed-by: Olivia Lee Part-of: --- src/gallium/drivers/panfrost/pan_shader.c | 6 ------ src/panfrost/compiler/bifrost_compile.c | 5 +++++ src/panfrost/vulkan/panvk_vX_shader.c | 6 ------ 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_shader.c b/src/gallium/drivers/panfrost/pan_shader.c index 733b2c9c374..5c714c09d17 100644 --- a/src/gallium/drivers/panfrost/pan_shader.c +++ b/src/gallium/drivers/panfrost/pan_shader.c @@ -519,12 +519,6 @@ panfrost_create_shader_state(struct pipe_context *pctx, if (dev->arch >= 6 && nir->info.stage == MESA_SHADER_FRAGMENT) NIR_PASS(_, nir, pan_nir_lower_noperspective_fs); - /* nir_lower[_explicit]_io is lazy and emits mul+add chains even for - * offsets it could figure out are constant. Do some constant folding - * before bifrost_nir_lower_store_component below. - */ - NIR_PASS(_, nir, nir_opt_constant_folding); - pan_shader_postprocess(nir, panfrost_device_gpu_id(dev)); if (nir->info.stage == MESA_SHADER_FRAGMENT) diff --git a/src/panfrost/compiler/bifrost_compile.c b/src/panfrost/compiler/bifrost_compile.c index 9de6adbc411..8204688783d 100644 --- a/src/panfrost/compiler/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost_compile.c @@ -6014,6 +6014,11 @@ bifrost_postprocess_nir(nir_shader *nir, unsigned gpu_id) VARYING_BIT_PSIZ, false); } + /* nir_lower[_explicit]_io is lazy and emits mul+add chains even + * for offsets it could figure out are constant. Do some + * constant folding before pan_nir_lower_store_component below. + */ + NIR_PASS(_, nir, nir_opt_constant_folding); NIR_PASS(_, nir, pan_nir_lower_store_component); } diff --git a/src/panfrost/vulkan/panvk_vX_shader.c b/src/panfrost/vulkan/panvk_vX_shader.c index ca1e2e0bd0f..ba3f04e287a 100644 --- a/src/panfrost/vulkan/panvk_vX_shader.c +++ b/src/panfrost/vulkan/panvk_vX_shader.c @@ -927,12 +927,6 @@ panvk_lower_nir(struct panvk_device *dev, nir_shader *nir, if (nir->info.stage == MESA_SHADER_FRAGMENT) NIR_PASS(_, nir, pan_nir_lower_noperspective_fs); - /* nir_lower[_explicit]_io is lazy and emits mul+add chains even for - * offsets it could figure out are constant. Do some constant folding - * before bifrost_nir_lower_store_component below. - */ - NIR_PASS(_, nir, nir_opt_constant_folding); - pan_shader_postprocess(nir, compile_input->gpu_id); if (stage == MESA_SHADER_VERTEX)