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 <timur.kristof@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14309>
This commit is contained in:
Emma Anholt 2022-01-11 10:23:51 -08:00 committed by Marge Bot
parent ec4b9909f0
commit 645ca56425

View file

@ -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);