summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2017-02-15 10:15:58 -0800
committerJason Ekstrand <[email protected]>2017-03-01 17:00:20 -0800
commit95972cd4fda18880c54453245c9512751adfc4ad (patch)
treebae5a57762a44b7c00d9a69132877b01ec8ffe5a /src/compiler/nir
parent3ce8eeb5a1252173f68c63e9b8341a71012e0e76 (diff)
nir/lower_indirect: Use nir_builder control-flow helpers
Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_lower_indirect_derefs.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/compiler/nir/nir_lower_indirect_derefs.c b/src/compiler/nir/nir_lower_indirect_derefs.c
index 09cc9a310b1..c949224b15c 100644
--- a/src/compiler/nir/nir_lower_indirect_derefs.c
+++ b/src/compiler/nir/nir_lower_indirect_derefs.c
@@ -55,41 +55,16 @@ 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_push_else(b, NULL);
emit_indirect_load_store(b, orig_instr, deref, arr_parent,
mid, end, &else_dest, src);
+ nir_pop_if(b, NULL);
- b->cursor = nir_after_cf_node(&if_stmt->cf_node);
-
- if (src == NULL) {
- /* We're a load. We need to insert a phi node */
- nir_phi_instr *phi = nir_phi_instr_create(b->shader);
- unsigned bit_size = then_dest->bit_size;
- nir_ssa_dest_init(&phi->instr, &phi->dest,
- 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->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->src = nir_src_for_ssa(else_dest);
- exec_list_push_tail(&phi->srcs, &src1->node);
-
- nir_builder_instr_insert(b, &phi->instr);
- *dest = &phi->dest.ssa;
- }
+ if (src == NULL)
+ *dest = nir_if_phi(b, then_dest, else_dest);
}
}