diff --git a/src/compiler/nir/nir_opt_loop_unroll.c b/src/compiler/nir/nir_opt_loop_unroll.c index a1ad0e59814..e0e0b754716 100644 --- a/src/compiler/nir/nir_opt_loop_unroll.c +++ b/src/compiler/nir/nir_opt_loop_unroll.c @@ -575,9 +575,17 @@ nir_opt_loop_unroll_impl(nir_function_impl *impl, &has_nested_loop); } - if (progress) + if (progress) { nir_lower_regs_to_ssa_impl(impl); + /* Calling nir_convert_loop_to_lcssa() adds extra phi nodes which may + * not be valid if they're used for something such as a deref. + * Remove any unneeded phis. + */ + nir_copy_prop(impl->function->shader); + nir_opt_remove_phis_impl(impl); + } + return progress; }