From 60578df33a3a06a04bd2ffab72c962521ec65519 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Wed, 16 Oct 2024 13:59:38 +0200 Subject: [PATCH] nir: skip offset=0 in nir_io_add_const_offset_to_base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When offset=0, the pass was a no-op but was setting the progress flag which could cause infinite loops when this pass is going to be added to gl_nir_opts. Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_lower_io.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 804ada1c575..c758992d141 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -3018,16 +3018,17 @@ add_const_offset_to_base_block(nir_block *block, nir_builder *b, !nir_intrinsic_io_semantics(intrin).per_view) { unsigned off = nir_src_as_uint(*offset); - nir_intrinsic_set_base(intrin, nir_intrinsic_base(intrin) + off); + if (off) { + nir_intrinsic_set_base(intrin, nir_intrinsic_base(intrin) + off); - sem.location += off; + sem.location += off; + b->cursor = nir_before_instr(&intrin->instr); + nir_src_rewrite(offset, nir_imm_int(b, 0)); + progress = true; + } /* non-indirect indexing should reduce num_slots */ sem.num_slots = is_dual_slot(intrin) ? 2 : 1; nir_intrinsic_set_io_semantics(intrin, sem); - - b->cursor = nir_before_instr(&intrin->instr); - nir_src_rewrite(offset, nir_imm_int(b, 0)); - progress = true; } } }