From 12d7f911c968fada2bfb03c33a211d1d09fe7573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 25 Mar 2022 12:03:27 +0100 Subject: [PATCH] aco/optimizer: prevent any overflow between SGPR and const offset on MUBUF Apparently, if the SGPR offset + const offset overflows, it doesn't work. Totals from 145 (0.11% of 134913) affected shaders: (GFX10.3) SpillSGPRs: 134 -> 104 (-22.39%) CodeSize: 1632676 -> 1645916 (+0.81%); split: -0.03%, +0.84% Instrs: 316920 -> 320252 (+1.05%); split: -0.01%, +1.07% Latency: 1456285 -> 1459686 (+0.23%); split: -0.02%, +0.25% InvThroughput: 165785 -> 166086 (+0.18%); split: -0.02%, +0.20% VClause: 6815 -> 6875 (+0.88%); split: -0.03%, +0.91% SClause: 19089 -> 19079 (-0.05%); split: -0.06%, +0.01% PreSGPRs: 7302 -> 7304 (+0.03%); split: -0.01%, +0.04% Fixes: KHR-GL45.shader_storage_buffer_object.basic-operations-case1-cs Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_optimizer.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index e2f540c94e3..cddc3f194b1 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -1345,7 +1345,6 @@ label_instruction(opt_ctx& ctx, aco_ptr& instr) * addressing works significantly, this probably applies to swizzled * MUBUF accesses. */ bool vaddr_prevent_overflow = mubuf.swizzled && ctx.program->chip_class < GFX9; - bool saddr_prevent_overflow = mubuf.swizzled; if (mubuf.offen && i == 1 && info.is_constant_or_literal(32) && mubuf.offset + info.val < 4096) { @@ -1366,9 +1365,7 @@ label_instruction(opt_ctx& ctx, aco_ptr& instr) instr->operands[1].setTemp(base); mubuf.offset += offset; continue; - } else if (i == 2 && - parse_base_offset(ctx, instr.get(), i, &base, &offset, - saddr_prevent_overflow) && + } else if (i == 2 && parse_base_offset(ctx, instr.get(), i, &base, &offset, true) && base.regClass() == s1 && mubuf.offset + offset < 4096) { instr->operands[i].setTemp(base); mubuf.offset += offset;