ir3: Add loop depth to ir3_block
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 23 Jul 2021 11:05:50 +0000 (13:05 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 20 Aug 2021 10:37:36 +0000 (10:37 +0000)
And while we're at it, fix adding loop_id for the continue block.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12033>

src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_context.h

index 624a416..0512d8b 100644 (file)
@@ -588,6 +588,7 @@ struct ir3_block {
    uint32_t dom_post_index;
 
    uint32_t loop_id;
+   uint32_t loop_depth;
 
 #ifdef DEBUG
    uint32_t serialno;
index 16be6e1..e3c10be 100644 (file)
@@ -2984,6 +2984,7 @@ emit_block(struct ir3_context *ctx, nir_block *nblock)
    list_addtail(&ctx->block->node, &ctx->ir->block_list);
 
    ctx->block->loop_id = ctx->loop_id;
+   ctx->block->loop_depth = ctx->loop_depth;
 
    /* re-emit addr register in each block if needed: */
    for (int i = 0; i < ARRAY_SIZE(ctx->addr0_ht); i++) {
@@ -3056,6 +3057,7 @@ emit_loop(struct ir3_context *ctx, nir_loop *nloop)
 {
    unsigned old_loop_id = ctx->loop_id;
    ctx->loop_id = ctx->so->loops + 1;
+   ctx->loop_depth++;
 
    struct nir_block *nstart = nir_loop_first_block(nloop);
    struct ir3_block *continue_blk = NULL;
@@ -3075,10 +3077,13 @@ emit_loop(struct ir3_context *ctx, nir_loop *nloop)
       struct ir3_block *start = get_block(ctx, nstart);
       continue_blk->successors[0] = start;
       continue_blk->physical_successors[0] = start;
+      continue_blk->loop_id = ctx->loop_id;
+      continue_blk->loop_depth = ctx->loop_depth;
       list_addtail(&continue_blk->node, &ctx->ir->block_list);
    }
 
    ctx->so->loops++;
+   ctx->loop_depth--;
    ctx->loop_id = old_loop_id;
 }
 
index 18dfcab..844f146 100644 (file)
@@ -114,6 +114,7 @@ struct ir3_context {
    unsigned stack, max_stack;
 
    unsigned loop_id;
+   unsigned loop_depth;
 
    /* a common pattern for indirect addressing is to request the
     * same address register multiple times.  To avoid generating