agx: Zero r0l before first use of control flow
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11023>
This commit is contained in:
@@ -847,6 +847,24 @@ emit_loop(agx_context *ctx, nir_loop *nloop)
|
|||||||
assert(ctx->loop_nesting == 0);
|
assert(ctx->loop_nesting == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Before the first control flow structure, the nesting counter (r0l) needs to
|
||||||
|
* be zeroed for correct operation. This only happens at most once, since by
|
||||||
|
* definition this occurs at the end of the first block, which dominates the
|
||||||
|
* rest of the program. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
emit_first_cf(agx_context *ctx)
|
||||||
|
{
|
||||||
|
if (ctx->any_cf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
agx_builder _b = agx_init_builder(ctx, agx_after_block(ctx->current_block));
|
||||||
|
agx_index r0l = agx_register(0, false);
|
||||||
|
|
||||||
|
agx_mov_to(&_b, r0l, agx_immediate(0));
|
||||||
|
ctx->any_cf = true;
|
||||||
|
}
|
||||||
|
|
||||||
static agx_block *
|
static agx_block *
|
||||||
emit_cf_list(agx_context *ctx, struct exec_list *list)
|
emit_cf_list(agx_context *ctx, struct exec_list *list)
|
||||||
{
|
{
|
||||||
@@ -864,10 +882,12 @@ emit_cf_list(agx_context *ctx, struct exec_list *list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case nir_cf_node_if:
|
case nir_cf_node_if:
|
||||||
|
emit_first_cf(ctx);
|
||||||
emit_if(ctx, nir_cf_node_as_if(node));
|
emit_if(ctx, nir_cf_node_as_if(node));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nir_cf_node_loop:
|
case nir_cf_node_loop:
|
||||||
|
emit_first_cf(ctx);
|
||||||
emit_loop(ctx, nir_cf_node_as_loop(node));
|
emit_loop(ctx, nir_cf_node_as_loop(node));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -334,6 +334,9 @@ typedef struct {
|
|||||||
/* I don't really understand how writeout ops work yet */
|
/* I don't really understand how writeout ops work yet */
|
||||||
bool did_writeout;
|
bool did_writeout;
|
||||||
|
|
||||||
|
/* Has r0l been zeroed yet due to control flow? */
|
||||||
|
bool any_cf;
|
||||||
|
|
||||||
/* Number of nested control flow structures within the innermost loop. Since
|
/* Number of nested control flow structures within the innermost loop. Since
|
||||||
* NIR is just loop and if-else, this is the number of nested if-else
|
* NIR is just loop and if-else, this is the number of nested if-else
|
||||||
* statements in the loop */
|
* statements in the loop */
|
||||||
|
Reference in New Issue
Block a user