From a8c91f15f0339bf03fae5b0712e4a657f8d09c72 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Sun, 3 Jan 2021 22:03:57 +1300 Subject: [PATCH] pan/mdg: Fix spilling when scratch memory is used Add the tls_size from NIR before spilling so that it doesn't alias with spill slots. Fixes: 152bc5d15e1 ("pan/mdg: Support loads and stores to scratch memory") Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_ra.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index 04be27d..72c06ad 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -1011,7 +1011,7 @@ mir_ra(compiler_context *ctx) int iter_count = 1000; /* max iterations */ /* Number of 128-bit slots in memory we've spilled into */ - unsigned spill_count = 0; + unsigned spill_count = DIV_ROUND_UP(ctx->tls_size, 16); mir_create_pipeline_registers(ctx); @@ -1054,7 +1054,7 @@ mir_ra(compiler_context *ctx) /* Report spilling information. spill_count is in 128-bit slots (vec4 x * fp32), but tls_size is in bytes, so multiply by 16 */ - ctx->tls_size += spill_count * 16; + ctx->tls_size = spill_count * 16; install_registers(ctx, l); -- 2.7.4