nir_lower_mem_access_bit_sizes: fix negative chunk offsets

With a 64 bit pointer model, instead of doing -1 the pass ended up doing
+4294967295. The reason here was some implicit integer conversion going
horribly wrong, so just do the offset math in 64 bit to get a nice result.

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13023
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34669>
This commit is contained in:
Karol Herbst 2025-04-23 11:54:05 +02:00 committed by Marge Bot
parent 4685d8e2d9
commit 33965bb21b

View file

@ -239,7 +239,7 @@ lower_mem_load(nir_builder *b, nir_intrinsic_instr *intrin,
/* In this case, we know how much to adjust the offset */
uint32_t delta = chunk_align_offset % requested.align;
nir_def *load_offset =
nir_iadd_imm(b, offset, chunk_start - (int)delta);
nir_iadd_imm(b, offset, (int64_t)chunk_start - (int64_t)delta);
const uint32_t load_align_offset =
(chunk_align_offset - delta) % align_mul;