return false;
}
+ /* Same check for if-condition uses */
+ nir_foreach_if_use(use, def) {
+ nir_block *use_block =
+ nir_cf_node_as_block(nir_cf_node_prev(&use->parent_if->cf_node));
+
+ if (use_block->index <= before->index ||
+ use_block->index >= after->index)
+ return false;
+ }
+
return true;
}
nir_foreach_instr(instr, block) {
if (instr->type == nir_instr_type_call)
- return true;
+ return false;
/* Return instructions can cause us to skip over other side-effecting
* instructions after the loop, so consider them to have side effects
bool dummy;
progress |= dead_cf_list(&loop->body, &dummy);
+ nir_block *next = nir_cf_node_as_block(nir_cf_node_next(cur));
+ if (next->predecessors->entries == 0 &&
+ (!exec_list_is_empty(&next->instr_list) ||
+ !exec_node_is_tail_sentinel(next->cf_node.node.next))) {
+ remove_after_cf_node(cur);
+ return true;
+ }
break;
}
if (progress) {
nir_metadata_preserve(impl, nir_metadata_none);
- } else {
+
+ /* The CF manipulation code called by this pass is smart enough to keep
+ * from breaking any SSA use/def chains by replacing any uses of removed
+ * instructions with SSA undefs. However, it's not quite smart enough
+ * to always preserve the dominance properties. In particular, if you
+ * remove the one break from a loop, stuff in the loop may still be used
+ * outside the loop even though there's no path between the two. We can
+ * easily fix these issues by calling nir_repair_ssa which will ensure
+ * that the dominance properties hold.
+ */
+ nir_repair_ssa_impl(impl);
+ } else {
#ifndef NDEBUG
impl->valid_metadata &= ~nir_metadata_not_properly_reset;
#endif
- }
+ }
return progress;
}