From 0be2d71ad16cf07ac5dac2d3f4cc4fbe069bacfd Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 13 May 2026 16:07:36 +0200 Subject: [PATCH] nir/opt_uniform_subgroup: preserve divergence during optimization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nir_def_init sets divergent = true, this means for something like reduce(reduce(convergent)) we previously only optimized the inner reduce. No fossil changes at the moment, but I hit this when trying to optimize shared memory to subgroup operations. Reviewed-by: Lionel Landwerlin Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_opt_uniform_subgroup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/nir/nir_opt_uniform_subgroup.c b/src/compiler/nir/nir_opt_uniform_subgroup.c index 3f13d0e878d..d39bb496558 100644 --- a/src/compiler/nir/nir_opt_uniform_subgroup.c +++ b/src/compiler/nir/nir_opt_uniform_subgroup.c @@ -323,6 +323,12 @@ opt_uniform_subgroup_instr(nir_builder *b, nir_intrinsic_instr *intrin, void *_s return false; } + + /* Divergence shouldn't change from the optimization that we have done, + * so preserve it in case another subgroup operation uses the result. + */ + replacement->divergent = intrin->def.divergent; + nir_def_replace(&intrin->def, replacement); return true; }