summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmma Anholt <emma@anholt.net>2022-01-11 10:23:51 -0800
committerMarge Bot <emma+marge@anholt.net>2022-01-19 22:28:34 +0000
commit645ca56425a54ce56781f2650f2990cd4d50b6a1 (patch)
tree30d07d43ea1b1c3e006f0224f0d4e66c14a48658
parentec4b9909f040fff083ff3e787270ab713f8662fe (diff)
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>
-rw-r--r--src/compiler/nir/nir_opt_offsets.c2
1 files changed, 1 insertions, 1 deletions
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);