From 3a25c1241b345a8d4abd4a085e94bfc764ed97b2 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 22 Sep 2024 16:29:44 -0400 Subject: [PATCH] agx: validate sizes are consistent in the IR subtle correctness requirement for the spiller. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_validate.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/asahi/compiler/agx_validate.c b/src/asahi/compiler/agx_validate.c index 943edc247fd..8dcb20e13f2 100644 --- a/src/asahi/compiler/agx_validate.c +++ b/src/asahi/compiler/agx_validate.c @@ -359,6 +359,7 @@ static bool agx_validate_width(agx_context *ctx) { bool succ = true; + enum agx_size *sizes = calloc(ctx->alloc, sizeof(*sizes)); agx_foreach_instr_global(ctx, I) { agx_foreach_dest(I, d) { @@ -373,6 +374,9 @@ agx_validate_width(agx_context *ctx) agx_print_instr(I, stderr); fprintf(stderr, "\n"); } + + if (I->dest[d].type == AGX_INDEX_NORMAL) + sizes[I->dest[d].value] = I->dest[d].size; } agx_foreach_src(I, s) { @@ -393,6 +397,21 @@ agx_validate_width(agx_context *ctx) } } + /* Check sources after all defs processed for proper backedge handling */ + agx_foreach_instr_global(ctx, I) { + agx_foreach_ssa_src(I, s) { + if (sizes[I->src[s].value] != I->src[s].size) { + succ = false; + fprintf(stderr, "source %u, expected el size %u, got el size %u\n", + s, agx_size_align_16(sizes[I->src[s].value]), + agx_size_align_16(I->src[s].size)); + agx_print_instr(I, stderr); + fprintf(stderr, "\n"); + } + } + } + + free(sizes); return succ; }