aco: track divergent and uniform branch depth

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8994>
This commit is contained in:
Rhys Perry 2020-12-15 14:32:58 +00:00
parent 8f71be0a7b
commit 7d5643c0fe
2 changed files with 17 additions and 0 deletions

View file

@ -10073,7 +10073,9 @@ static void begin_divergent_if_then(isel_context *ctx, if_context *ic, Temp cond
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;
@ -10097,6 +10099,7 @@ static void begin_divergent_if_else(isel_context *ctx, if_context *ic)
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();
@ -10109,6 +10112,7 @@ static void begin_divergent_if_else(isel_context *ctx, if_context *ic)
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;
@ -10129,7 +10133,9 @@ static void begin_divergent_if_else(isel_context *ctx, if_context *ic)
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);
@ -10152,6 +10158,7 @@ static void end_divergent_if(isel_context *ctx, if_context *ic)
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;
@ -10216,7 +10223,9 @@ static void begin_uniform_if_then(isel_context *ctx, if_context *ic, Temp cond)
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);
@ -10275,7 +10284,9 @@ static void end_uniform_if(isel_context *ctx, if_context *ic)
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);

View file

@ -1670,6 +1670,8 @@ struct 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;
@ -1846,6 +1848,8 @@ public:
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,
@ -1887,6 +1891,8 @@ public:
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();
}