ctx->cf_info.exec_potentially_empty_break = false;
ctx->cf_info.exec_potentially_empty_break_depth = UINT16_MAX;
+
/** emit logical then block */
+ ctx->program->next_divergent_if_logical_depth++;
Block* BB_then_logical = ctx->program->create_and_insert_block();
add_edge(ic->BB_if_idx, BB_then_logical);
ctx->block = BB_then_logical;
assert(!ctx->cf_info.has_branch);
ic->then_branch_divergent = ctx->cf_info.parent_loop.has_divergent_branch;
ctx->cf_info.parent_loop.has_divergent_branch = false;
+ ctx->program->next_divergent_if_logical_depth--;
/** emit linear then block */
Block* BB_then_linear = ctx->program->create_and_insert_block();
BB_then_linear->instructions.emplace_back(std::move(branch));
add_linear_edge(BB_then_linear->index, &ic->BB_invert);
+
/** emit invert merge block */
ctx->block = ctx->program->insert_block(std::move(ic->BB_invert));
ic->invert_idx = ctx->block->index;
ctx->cf_info.exec_potentially_empty_break = false;
ctx->cf_info.exec_potentially_empty_break_depth = UINT16_MAX;
+
/** emit logical else block */
+ ctx->program->next_divergent_if_logical_depth++;
Block* BB_else_logical = ctx->program->create_and_insert_block();
add_logical_edge(ic->BB_if_idx, BB_else_logical);
add_linear_edge(ic->invert_idx, BB_else_logical);
if (!ctx->cf_info.parent_loop.has_divergent_branch)
add_logical_edge(BB_else_logical->index, &ic->BB_endif);
BB_else_logical->kind |= block_kind_uniform;
+ ctx->program->next_divergent_if_logical_depth--;
assert(!ctx->cf_info.has_branch);
ctx->cf_info.parent_loop.has_divergent_branch &= ic->then_branch_divergent;
ctx->cf_info.has_branch = false;
ctx->cf_info.parent_loop.has_divergent_branch = false;
+
/** emit then block */
+ ctx->program->next_uniform_if_depth++;
Block* BB_then = ctx->program->create_and_insert_block();
add_edge(ic->BB_if_idx, BB_then);
append_logical_start(BB_then);
ctx->cf_info.has_branch &= ic->uniform_has_then_branch;
ctx->cf_info.parent_loop.has_divergent_branch &= ic->then_branch_divergent;
+
/** emit endif merge block */
+ ctx->program->next_uniform_if_depth--;
if (!ctx->cf_info.has_branch) {
ctx->block = ctx->program->insert_block(std::move(ic->BB_endif));
append_logical_start(ctx->block);
std::vector<unsigned> linear_succs;
RegisterDemand register_demand = RegisterDemand();
uint16_t loop_nest_depth = 0;
+ uint16_t divergent_if_logical_depth = 0;
+ uint16_t uniform_if_depth = 0;
uint16_t kind = 0;
int logical_idom = -1;
int linear_idom = -1;
float_mode next_fp_mode;
unsigned next_loop_depth = 0;
+ unsigned next_divergent_if_logical_depth = 0;
+ unsigned next_uniform_if_depth = 0;
struct {
void (*func)(void *private_data,
block.index = blocks.size();
block.fp_mode = next_fp_mode;
block.loop_nest_depth = next_loop_depth;
+ block.divergent_if_logical_depth = next_divergent_if_logical_depth;
+ block.uniform_if_depth = next_uniform_if_depth;
blocks.emplace_back(std::move(block));
return &blocks.back();
}