brw: bound the amount of rematerialized NIR instructions

Some of the instructions we don't need to rematerialize because we
already know they are executed with NoMask so we can use their
destination without reemitting them again.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29663>
This commit is contained in:
Lionel Landwerlin
2024-06-17 12:59:05 +03:00
committed by Marge Bot
parent 4bfb4f35a8
commit d42bc0d3fc
+24 -1
View File
@@ -4539,6 +4539,28 @@ struct rebuild_resource {
std::vector<nir_def *> array;
};
static bool
skip_rebuild_instr(nir_instr *instr)
{
if (instr->type != nir_instr_type_intrinsic)
return false;
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
switch (intrin->intrinsic) {
case nir_intrinsic_load_ubo_uniform_block_intel:
case nir_intrinsic_load_ssbo_uniform_block_intel:
case nir_intrinsic_load_global_constant_uniform_block_intel:
/* Those intrinsic are generated using NoMask so we can trust their
* destination registers are fully populated. No need to rematerialize
* further.
*/
return true;
default:
return false;
}
}
static bool
add_rebuild_src(nir_src *src, void *state)
{
@@ -4549,7 +4571,8 @@ add_rebuild_src(nir_src *src, void *state)
return true;
}
nir_foreach_src(src->ssa->parent_instr, add_rebuild_src, state);
if (!skip_rebuild_instr(src->ssa->parent_instr))
nir_foreach_src(src->ssa->parent_instr, add_rebuild_src, state);
res->array.push_back(src->ssa);
return true;
}