nir/lower_returns: Use nir control flow insertion helpers

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6866>
This commit is contained in:
Connor Abbott
2019-04-10 11:34:57 +02:00
committed by Marge Bot
parent f103bded0b
commit c6f871b62e

View File

@@ -55,17 +55,13 @@ predicate_following(nir_cf_node *node, struct lower_returns_state *state)
assert(state->return_flag);
nir_if *if_stmt = nir_if_create(b->shader);
if_stmt->condition = nir_src_for_ssa(nir_load_var(b, state->return_flag));
nir_cf_node_insert(b->cursor, &if_stmt->cf_node);
nir_if *if_stmt = nir_push_if(b, nir_load_var(b, state->return_flag));
if (state->loop) {
/* If we're inside of a loop, then all we need to do is insert a
* conditional break.
*/
nir_jump_instr *brk =
nir_jump_instr_create(state->builder.shader, nir_jump_break);
nir_instr_insert(nir_before_cf_list(&if_stmt->then_list), &brk->instr);
nir_jump(b, nir_jump_break);
} else {
/* Otherwise, we need to actually move everything into the else case
* of the if statement.
@@ -76,6 +72,8 @@ predicate_following(nir_cf_node *node, struct lower_returns_state *state)
assert(!exec_list_is_empty(&list.list));
nir_cf_reinsert(&list, nir_before_cf_list(&if_stmt->else_list));
}
nir_pop_if(b, NULL);
}
static bool