nir/opt_uniform_subgroup: preserve divergence during optimization
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

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 <lionel.g.landwerlin@intel.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41542>
This commit is contained in:
Georg Lehmann 2026-05-13 16:07:36 +02:00 committed by Marge Bot
parent e44cb38c3b
commit 0be2d71ad1

View file

@ -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;
}