From 33965bb21bac40840cf07958f509dcada4ead979 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 23 Apr 2025 11:54:05 +0200 Subject: [PATCH] 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 Reviewed-by: Rhys Perry Part-of: --- src/compiler/nir/nir_lower_mem_access_bit_sizes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_lower_mem_access_bit_sizes.c b/src/compiler/nir/nir_lower_mem_access_bit_sizes.c index 2ae8d4a5302..39c761f0a39 100644 --- a/src/compiler/nir/nir_lower_mem_access_bit_sizes.c +++ b/src/compiler/nir/nir_lower_mem_access_bit_sizes.c @@ -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;