unlink_block_successors(block);
link_blocks(block, first_then_block, first_else_block);
- } else {
+ } else if (node->type == nir_cf_node_loop) {
/*
* For similar reasons as the corresponding case in
* link_non_block_to_block(), don't worry about if the loop header has
nir_block *first_else_block = nir_if_first_else_block(next_if);
link_blocks(block, first_then_block, first_else_block);
- } else {
+ } else if (next->type == nir_cf_node_loop) {
nir_loop *next_loop = nir_cf_node_as_loop(next);
nir_block *first_block = nir_loop_first_block(next_loop);
break;
}
+ case nir_jump_goto:
+ link_blocks(block, jump_instr->target, NULL);
+ break;
+
+ case nir_jump_goto_if:
+ link_blocks(block, jump_instr->else_target, jump_instr->target);
+ break;
+
default:
unreachable("Invalid jump type");
}
/* We need to walk the instructions and clean up defs/uses */
nir_foreach_instr_safe(instr, block) {
if (instr->type == nir_instr_type_jump) {
- nir_jump_type jump_type = nir_instr_as_jump(instr)->type;
- unlink_jump(block, jump_type, false);
+ nir_jump_instr *jump = nir_instr_as_jump(instr);
+ unlink_jump(block, jump->type, false);
+ if (jump->type == nir_jump_goto_if)
+ nir_instr_rewrite_src(instr, &jump->condition, NIR_SRC_INIT);
} else {
nir_foreach_ssa_def(instr, replace_ssa_def_uses, impl);
nir_instr_remove(instr);