[Mesa-dev] [PATCH 4/5] nir/lower_indirect: Use nir_builder control-flow helpers
Jason Ekstrand
jason at jlekstrand.net
Wed Feb 15 22:59:17 UTC 2017
---
src/compiler/nir/nir_lower_indirect_derefs.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/compiler/nir/nir_lower_indirect_derefs.c b/src/compiler/nir/nir_lower_indirect_derefs.c
index 09cc9a3..52adde8 100644
--- a/src/compiler/nir/nir_lower_indirect_derefs.c
+++ b/src/compiler/nir/nir_lower_indirect_derefs.c
@@ -55,20 +55,15 @@ emit_indirect_load_store(nir_builder *b, nir_intrinsic_instr *orig_instr,
nir_ssa_def *then_dest, *else_dest;
- nir_if *if_stmt = nir_if_create(b->shader);
- if_stmt->condition = nir_src_for_ssa(nir_ilt(b, arr->indirect.ssa,
- nir_imm_int(b, mid)));
- nir_cf_node_insert(b->cursor, &if_stmt->cf_node);
-
- b->cursor = nir_after_cf_list(&if_stmt->then_list);
+ nir_push_if(b, nir_ilt(b, arr->indirect.ssa, nir_imm_int(b, mid)));
emit_indirect_load_store(b, orig_instr, deref, arr_parent,
start, mid, &then_dest, src);
-
- b->cursor = nir_after_cf_list(&if_stmt->else_list);
+ nir_block *then_block = nir_cursor_current_block(b->cursor);
+ nir_push_else(b, NULL);
emit_indirect_load_store(b, orig_instr, deref, arr_parent,
mid, end, &else_dest, src);
-
- b->cursor = nir_after_cf_node(&if_stmt->cf_node);
+ nir_block *else_block = nir_cursor_current_block(b->cursor);
+ nir_pop_if(b, NULL);
if (src == NULL) {
/* We're a load. We need to insert a phi node */
@@ -78,12 +73,12 @@ emit_indirect_load_store(nir_builder *b, nir_intrinsic_instr *orig_instr,
then_dest->num_components, bit_size, NULL);
nir_phi_src *src0 = ralloc(phi, nir_phi_src);
- src0->pred = nir_if_last_then_block(if_stmt);
+ src0->pred = then_block;
src0->src = nir_src_for_ssa(then_dest);
exec_list_push_tail(&phi->srcs, &src0->node);
nir_phi_src *src1 = ralloc(phi, nir_phi_src);
- src1->pred = nir_if_last_else_block(if_stmt);
+ src1->pred = else_block;
src1->src = nir_src_for_ssa(else_dest);
exec_list_push_tail(&phi->srcs, &src1->node);
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list