aco: fix global_atomic_swap offset overflow check

Fixes: d7dcd81c77 ("aco/gfx6: allow both constant and gpr offset for global with sgpr address")

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37821>
(cherry picked from commit c13caa5e5f)
This commit is contained in:
Georg Lehmann 2025-10-10 18:30:55 +02:00 committed by Eric Engestrom
parent d675c21ed4
commit 5463ea2701
2 changed files with 7 additions and 3 deletions

View file

@ -1744,7 +1744,7 @@
"description": "aco: fix global_atomic_swap offset overflow check",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "d7dcd81c77efffce2ef122254c9dfc9dbb3bf447",
"notes": null

View file

@ -2667,10 +2667,13 @@ visit_global_atomic(isel_context* ctx, nir_intrinsic_instr* instr)
const nir_atomic_op nir_op = nir_intrinsic_atomic_op(instr);
const bool cmpswap = nir_op == nir_atomic_op_cmpxchg;
unsigned offset_idx = 2;
if (cmpswap)
if (cmpswap) {
offset_idx = 3;
data = bld.pseudo(aco_opcode::p_create_vector, bld.def(RegType::vgpr, data.size() * 2),
get_ssa_temp(ctx, instr->src[2].ssa), data);
}
Temp dst = get_ssa_temp(ctx, &instr->def);
@ -2679,7 +2682,8 @@ visit_global_atomic(isel_context* ctx, nir_intrinsic_instr* instr)
Temp addr, offset;
uint32_t const_offset;
parse_global(ctx, instr, &addr, &const_offset, &offset);
Format format = lower_global_address(ctx, bld, 0, &addr, &const_offset, &offset, &instr->src[2]);
Format format =
lower_global_address(ctx, bld, 0, &addr, &const_offset, &offset, &instr->src[offset_idx]);
if (format != Format::MUBUF) {
bool global = format == Format::GLOBAL;