Module: Mesa
Branch: main
Commit: 645ca56425a54ce56781f2650f2990cd4d50b6a1
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=645ca56425a54ce56781f2650f2990cd4d50b6a1

Author: Emma Anholt <[email protected]>
Date:   Tue Jan 11 10:23:51 2022 -0800

nir/opt_offsets: Also apply the max offset to top-level constant folding.

nir_to_tgsi wants this for disabling folding into shared var accesses at
all.

Reviewed-by: Timur Kristóf <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14309>

---

 src/compiler/nir/nir_opt_offsets.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_opt_offsets.c 
b/src/compiler/nir/nir_opt_offsets.c
index d833f0448a2..f9f54789693 100644
--- a/src/compiler/nir/nir_opt_offsets.c
+++ b/src/compiler/nir/nir_opt_offsets.c
@@ -114,7 +114,7 @@ try_fold_load_store(nir_builder *b,
 
    if (!nir_src_is_const(*off_src)) {
       replace_src = try_extract_const_addition(b, off_src->ssa->parent_instr, 
state, &off_const, max);
-   } else if (nir_src_as_uint(*off_src)) {
+   } else if (nir_src_as_uint(*off_src) && nir_src_as_uint(*off_src) < max) {
       off_const += nir_src_as_uint(*off_src);
       b->cursor = nir_before_instr(&intrin->instr);
       replace_src = nir_imm_zero(b, off_src->ssa->num_components, 
off_src->ssa->bit_size);

Reply via email to