mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
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> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32118>
This commit is contained in:
parent
73d513c5be
commit
b501cbf153
1 changed files with 4 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue