nir/nir_opt_offsets: Do not fold load/store with const offset > max
When (off_const > max) there is a wrap around uint when calling
try_extract_const_addition.
Exit early since folding doesn't make sense in this case.
Cc: mesa-stable
Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
(cherry picked from commit b501cbf153
)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32261>
This commit is contained in:

committed by
Dylan Baker

parent
743b2fdf8e
commit
bd8fb8a930
@@ -94,7 +94,7 @@
|
||||
"description": "nir/nir_opt_offsets: Do not fold load/store with const offset > max",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
@@ -116,6 +116,9 @@ try_fold_load_store(nir_builder *b,
|
||||
if (off_src->ssa->bit_size != 32)
|
||||
return false;
|
||||
|
||||
if (off_const > max)
|
||||
return false;
|
||||
|
||||
if (!nir_src_is_const(*off_src)) {
|
||||
uint32_t add_offset = 0;
|
||||
nir_scalar val = { .def = off_src->ssa, .comp = 0 };
|
||||
@@ -125,7 +128,7 @@ try_fold_load_store(nir_builder *b,
|
||||
off_const += add_offset;
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
replace_src = nir_channel(b, val.def, val.comp);
|
||||
} else if (nir_src_as_uint(*off_src) && off_const + nir_src_as_uint(*off_src) <= max) {
|
||||
} else if (nir_src_as_uint(*off_src) && nir_src_as_uint(*off_src) <= max - off_const) {
|
||||
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);
|
||||
|
Reference in New Issue
Block a user