bool nir_opt_rematerialize_compares(nir_shader *shader);
bool nir_opt_remove_phis(nir_shader *shader);
+bool nir_opt_remove_phis_block(nir_block *block);
bool nir_opt_shrink_load(nir_shader *shader);
if (!nir_is_trivial_loop_if(nif, break_blk))
return false;
+ /* Even though this if statement has a jump on one side, we may still have
+ * phis afterwards. Single-source phis can be produced by loop unrolling
+ * or dead control-flow passes and are perfectly legal. Run a quick phi
+ * removal on the block after the if to clean up any such phis.
+ */
+ nir_opt_remove_phis_block(nir_cf_node_as_block(nir_cf_node_next(&nif->cf_node)));
+
/* Finally, move the continue from branch after the if-statement. */
nir_cf_list tmp;
nir_cf_extract(&tmp, nir_before_block(first_continue_from_blk),
return progress;
}
+bool
+nir_opt_remove_phis_block(nir_block *block)
+{
+ nir_builder b;
+ nir_builder_init(&b, nir_cf_node_get_function(&block->cf_node));
+ return remove_phis_block(block, &b);
+}
+
static bool
nir_opt_remove_phis_impl(nir_function_impl *impl)
{