From d42bc0d3fcbe929d6e4a85ff770379843c4dd7c7 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Mon, 17 Jun 2024 12:59:05 +0300 Subject: [PATCH] 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 Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_fs_nir.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/intel/compiler/brw_fs_nir.cpp b/src/intel/compiler/brw_fs_nir.cpp index de5fe94b1b6..01ac12cad89 100644 --- a/src/intel/compiler/brw_fs_nir.cpp +++ b/src/intel/compiler/brw_fs_nir.cpp @@ -4539,6 +4539,28 @@ struct rebuild_resource { std::vector 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; }