From be5357a353b2cbb189b9e203868003d29b9842cb Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 21 Sep 2022 23:40:14 -0400 Subject: [PATCH] agx: Free dests of splits that are never read Otherwise the registers "leak", bloating register pressure by arbitrarily large amounts. This is easy to handle in DCE by rewriting to a null destination, though we could use a sideband channel if we didn't want null destinations in the IR. glmark2 subset of shader-db is much improved: total instructions in shared programs: 7324 -> 7313 (-0.15%) instructions in affected programs: 483 -> 472 (-2.28%) helped: 5 HURT: 2 total bytes in shared programs: 42788 -> 42722 (-0.15%) bytes in affected programs: 2808 -> 2742 (-2.35%) helped: 5 HURT: 2 total halfregs in shared programs: 2421 -> 2058 (-14.99%) halfregs in affected programs: 1235 -> 872 (-29.39%) helped: 28 HURT: 0 Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_dce.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/asahi/compiler/agx_dce.c b/src/asahi/compiler/agx_dce.c index 25c53252847..929e1caa1aa 100644 --- a/src/asahi/compiler/agx_dce.c +++ b/src/asahi/compiler/agx_dce.c @@ -47,10 +47,17 @@ agx_dce(agx_context *ctx) bool needed = false; agx_foreach_dest(I, d) { - if (I->dest[d].type == AGX_INDEX_NORMAL) - needed |= BITSET_TEST(seen, I->dest[d].value); - else if (I->dest[d].type != AGX_INDEX_NULL) - needed = true; + /* Eliminate destinations that are never read, as RA needs to + * handle them specially. Visible only for instructions that write + * multiple destinations (splits) or that write a destination but + * cannot be DCE'd (atomics). + */ + if ((I->dest[d].type == AGX_INDEX_NORMAL) && + !BITSET_TEST(seen, I->dest[d].value)) + I->dest[d] = agx_null(); + + /* If the destination is actually needed, the instruction is too */ + needed |= (I->dest[d].type != AGX_INDEX_NULL); } if (!needed) {