Mesa (master): aco: track divergent and uniform branch depth
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Mar 11 16:41:21 UTC 2021
Module: Mesa
Branch: master
Commit: 7d5643c0fe43bc87f0d405e9ba667496cbea551a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d5643c0fe43bc87f0d405e9ba667496cbea551a
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Tue Dec 15 14:32:58 2020 +0000
aco: track divergent and uniform branch depth
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8994>
---
src/amd/compiler/aco_instruction_selection.cpp | 11 +++++++++++
src/amd/compiler/aco_ir.h | 6 ++++++
2 files changed, 17 insertions(+)
diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp
index 14e68872de6..eda4e9d4340 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -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);
diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h
index d1ebb849cac..7d8e3cec64b 100644
--- a/src/amd/compiler/aco_ir.h
+++ b/src/amd/compiler/aco_ir.h
@@ -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();
}
More information about the mesa-commit
mailing list