Now that SSA values can be derefs and they have special rules, we have
to be a bit more careful about our LCSSA phis. In particular, we need
to clean up in case LCSSA ended up creating a phi node for a deref.
This fixes validation issues with some Vulkan CTS tests with the new
deref instructions.
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
bool nir_opt_peephole_select(nir_shader *shader, unsigned limit);
+bool nir_opt_remove_phis_impl(nir_function_impl *impl);
bool nir_opt_remove_phis(nir_shader *shader);
bool nir_opt_shrink_load(nir_shader *shader);
* that don't dominate their uses.
*/
nir_lower_regs_to_ssa_impl(function->impl);
+
+ /* Calling nir_convert_loop_to_lcssa() in opt_peel_loop_initial_if()
+ * adds extra phi nodes which may not be valid if they're used for
+ * something such as a deref. Remove any unneeded phis.
+ */
+ nir_opt_remove_phis_impl(function->impl);
+
progress = true;
}
}
return progress;
}
-static bool
-remove_phis_impl(nir_function_impl *impl)
+bool
+nir_opt_remove_phis_impl(nir_function_impl *impl)
{
bool progress = false;
nir_builder bld;
nir_foreach_function(function, shader)
if (function->impl)
- progress = remove_phis_impl(function->impl) || progress;
+ progress = nir_opt_remove_phis_impl(function->impl) || progress;
return progress;
}