[Mesa-dev] [RFC 1/5] nir/gcm: Compute the if-depth of each block
Jason Ekstrand
jason at jlekstrand.net
Sat Jan 14 22:37:37 UTC 2017
---
src/compiler/nir/nir_opt_gcm.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c
index cff2315..72ddc54 100644
--- a/src/compiler/nir/nir_opt_gcm.c
+++ b/src/compiler/nir/nir_opt_gcm.c
@@ -38,6 +38,9 @@
*/
struct gcm_block_info {
+ /* Number of if statements this block is inside */
+ unsigned if_depth;
+
/* Number of loops this block is inside */
unsigned loop_depth;
@@ -73,24 +76,28 @@ struct gcm_state {
/* Recursively walks the CFG and builds the block_info structure */
static void
gcm_build_block_info(struct exec_list *cf_list, struct gcm_state *state,
- unsigned loop_depth)
+ unsigned if_depth, unsigned loop_depth)
{
foreach_list_typed(nir_cf_node, node, node, cf_list) {
switch (node->type) {
case nir_cf_node_block: {
nir_block *block = nir_cf_node_as_block(node);
+ state->blocks[block->index].if_depth = if_depth;
state->blocks[block->index].loop_depth = loop_depth;
break;
}
case nir_cf_node_if: {
nir_if *if_stmt = nir_cf_node_as_if(node);
- gcm_build_block_info(&if_stmt->then_list, state, loop_depth);
- gcm_build_block_info(&if_stmt->else_list, state, loop_depth);
+ gcm_build_block_info(&if_stmt->then_list, state,
+ if_depth + 1, loop_depth);
+ gcm_build_block_info(&if_stmt->else_list, state,
+ if_depth + 1, loop_depth);
break;
}
case nir_cf_node_loop: {
nir_loop *loop = nir_cf_node_as_loop(node);
- gcm_build_block_info(&loop->body, state, loop_depth + 1);
+ gcm_build_block_info(&loop->body, state,
+ if_depth, loop_depth + 1);
break;
}
default:
@@ -466,7 +473,7 @@ opt_gcm_impl(nir_function_impl *impl, bool value_number)
nir_metadata_require(impl, nir_metadata_block_index |
nir_metadata_dominance);
- gcm_build_block_info(&impl->body, &state, 0);
+ gcm_build_block_info(&impl->body, &state, 0, 0);
nir_foreach_block(block, impl) {
gcm_pin_instructions_block(block, &state);
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list