nir/lower_io: Emit less iadd(x, 0)
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Sun, 7 May 2023 09:53:21 +0000 (11:53 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 10 May 2023 16:21:34 +0000 (16:21 +0000)
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22890>

src/compiler/nir/nir_lower_io.c

index ec8b6bf..2838807 100644 (file)
@@ -908,6 +908,9 @@ build_addr_iadd_imm(nir_builder *b, nir_ssa_def *addr,
                     nir_variable_mode modes,
                     int64_t offset)
 {
+   if (!offset)
+      return addr;
+
    return build_addr_iadd(b, addr, addr_format, modes,
                              nir_imm_intN_t(b, offset,
                                             addr_get_offset_bit_size(addr, addr_format)));