From 2a174f0019a614416f31416fd7c039557adc87bf Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 3 Mar 2023 16:19:17 -0500 Subject: [PATCH] agx/lower_address: Handle 16-bit offsets These need to be upconverted for correctness. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_nir_lower_address.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/asahi/compiler/agx_nir_lower_address.c b/src/asahi/compiler/agx_nir_lower_address.c index 7853efd4409..0279d5466da 100644 --- a/src/asahi/compiler/agx_nir_lower_address.c +++ b/src/asahi/compiler/agx_nir_lower_address.c @@ -224,6 +224,18 @@ pass(struct nir_builder *b, nir_instr *instr, UNUSED void *data) match.shift = 0; } + /* Hardware offsets must be 32-bits. Upconvert if the source code used + * smaller integers. + */ + if (offset->bit_size != 32) { + assert(offset->bit_size < 32); + + if (match.sign_extend) + offset = nir_i2i32(b, offset); + else + offset = nir_u2u32(b, offset); + } + assert(match.shift >= 0); nir_ssa_def *new_base = nir_channel(b, match.base.def, match.base.comp);