nir/propagate_invariant: include derefs

In case an array index is calculated using floating point.

fossil-db (navi21):
Totals from 1339 (0.66% of 202427) affected shaders:
MaxWaves: 30368 -> 30396 (+0.09%)
Instrs: 805468 -> 817035 (+1.44%); split: -0.00%, +1.44%
CodeSize: 4084432 -> 4130548 (+1.13%); split: -0.01%, +1.14%
VGPRs: 62000 -> 61952 (-0.08%)
Latency: 3885607 -> 3903915 (+0.47%); split: -0.01%, +0.48%
InvThroughput: 726350 -> 742176 (+2.18%); split: -0.03%, +2.21%
VClause: 22187 -> 22676 (+2.20%); split: -0.14%, +2.34%
SClause: 14663 -> 14616 (-0.32%); split: -0.42%, +0.10%
Copies: 65726 -> 65840 (+0.17%); split: -0.09%, +0.26%
Branches: 21075 -> 21076 (+0.00%); split: -0.02%, +0.03%
PreVGPRs: 48970 -> 48941 (-0.06%)
VALU: 454510 -> 466082 (+2.55%); split: -0.01%, +2.55%
SALU: 130543 -> 130521 (-0.02%); split: -0.03%, +0.01%
VMEM: 43876 -> 43896 (+0.05%)

Most of these changes are elden_ring shaders which can no longer optimize
f2u32(u2f32()).

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40740>
This commit is contained in:
Rhys Perry 2026-03-31 13:33:36 +01:00 committed by Marge Bot
parent 75ccfd8fb2
commit b6f9a9092a

View file

@ -89,9 +89,9 @@ propagate_invariant_instr(nir_instr *instr, struct set *invariants)
break;
}
case nir_instr_type_tex: {
nir_tex_instr *tex = nir_instr_as_tex(instr);
if (def_is_invariant(&tex->def, invariants))
case nir_instr_type_tex:
case nir_instr_type_deref: {
if (def_is_invariant(nir_instr_def(instr), invariants))
nir_foreach_src(instr, add_src_cb, invariants);
break;
}
@ -132,7 +132,6 @@ propagate_invariant_instr(nir_instr *instr, struct set *invariants)
break;
}
case nir_instr_type_deref:
case nir_instr_type_jump:
case nir_instr_type_undef:
case nir_instr_type_load_const: