mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 21:30:09 +01:00
nir/opt_large_constants: Fix dead deref instructions accessing lowered variables
It could happen that unused derefs weren't removed
if DCE wasn't called prior to nir_opt_large_constants.
Cc: mesa-stable
(cherry picked from commit 0d70716c8a)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38803>
This commit is contained in:
parent
8b20f43336
commit
19cab16a87
2 changed files with 16 additions and 1 deletions
|
|
@ -904,7 +904,7 @@
|
|||
"description": "nir/opt_large_constants: Fix dead deref instructions accessing lowered variables",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -481,6 +481,10 @@ nir_opt_large_constants(nir_shader *shader,
|
|||
/* Fix up indices after we sorted. */
|
||||
info->var->index = i;
|
||||
|
||||
/* Don't bother with dead variables. */
|
||||
if (info->constant_data_size == 0)
|
||||
info->is_constant = false;
|
||||
|
||||
if (!info->is_constant)
|
||||
continue;
|
||||
|
||||
|
|
@ -529,6 +533,17 @@ nir_opt_large_constants(nir_shader *shader,
|
|||
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_deref) {
|
||||
/* Ensure all derefs accessing the lowered arrays get removed. */
|
||||
nir_deref_instr *deref = nir_instr_as_deref(instr);
|
||||
if (!nir_deref_mode_is(deref, nir_var_function_temp))
|
||||
continue;
|
||||
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
if (var && var_infos[var->index].is_constant)
|
||||
nir_deref_instr_remove_if_unused(deref);
|
||||
}
|
||||
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue