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 <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15866>
This commit is contained in:
Daniel Schürmann
2022-03-25 12:03:27 +01:00
committed by Marge Bot
parent d5dc0c0392
commit 12d7f911c9

View File

@@ -1345,7 +1345,6 @@ label_instruction(opt_ctx& ctx, aco_ptr<Instruction>& 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<Instruction>& 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;