- 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);
- 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);
- 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);
-
- if (src == NULL) {
- /* We're a load. We need to insert a phi node */
- nir_phi_instr *phi = nir_phi_instr_create(b->shader);
- nir_ssa_dest_init(&phi->instr, &phi->dest,
- then_dest->num_components, NULL);
-
- nir_phi_src *src0 = ralloc(phi, nir_phi_src);
- src0->pred = nir_cf_node_as_block(nir_if_last_then_node(if_stmt));
- src0->src = nir_src_for_ssa(then_dest);
- exec_list_push_tail(&phi->srcs, &src0->node);