diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index d7cee0649b7..6373bf4dbda 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -368,7 +368,7 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_graphics_stat nir_move_options sink_opts = nir_move_const_undef | nir_move_copies | nir_dont_move_byte_word_vecs; if (!stage->key.optimisations_disabled) { - NIR_PASS(_, stage->nir, nir_opt_licm, NULL, ac_nir_opt_licm_filter_instr_cb); + NIR_PASS(_, stage->nir, nir_opt_licm, ac_nir_opt_licm_filter_instr_cb); if (stage->stage == MESA_SHADER_VERTEX) { /* Always load all VS inputs at the top to eliminate needless VMEM->s_wait->VMEM sequences. diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 98ea6ca4b09..6c2791b592e 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -6412,17 +6412,13 @@ bool nir_opt_large_constants(nir_shader *shader, glsl_type_size_align_func size_align, unsigned threshold); -typedef bool (*nir_opt_licm_filter_block_cb)(nir_block *block, nir_loop *loop); typedef bool (*nir_opt_licm_filter_instr_cb)(nir_instr *instr, bool instr_dominates_exit, unsigned num_dst_bits, unsigned num_all_src_bits, nir_loop *loop); -bool nir_opt_licm_filter_blocks_dominating_exit(nir_block *block, - nir_loop *loop); bool nir_opt_licm(nir_shader *shader, - nir_opt_licm_filter_block_cb filter_block, nir_opt_licm_filter_instr_cb filter_instr); bool nir_opt_loop(nir_shader *shader); diff --git a/src/compiler/nir/nir_opt_licm.c b/src/compiler/nir/nir_opt_licm.c index 758847ee6f6..0b5c2d35ce9 100644 --- a/src/compiler/nir/nir_opt_licm.c +++ b/src/compiler/nir/nir_opt_licm.c @@ -6,7 +6,6 @@ #include "nir.h" typedef struct { - nir_opt_licm_filter_block_cb filter_block; nir_opt_licm_filter_instr_cb filter_instr; nir_loop *loop; @@ -156,8 +155,7 @@ visit_cf_list(struct exec_list *list, licm_state *state) /* Visit the block. */ nir_block *block = nir_cf_node_as_block(node); - if (state->loop && - (!state->filter_block || state->filter_block(block, state->loop))) + if (state->loop) progress |= visit_block(block, state); if (next && next->type == nir_cf_node_loop && !optimize_loop) { @@ -190,23 +188,9 @@ visit_cf_list(struct exec_list *list, licm_state *state) } bool -nir_opt_licm_filter_blocks_dominating_exit(nir_block *block, nir_loop *loop) +nir_opt_licm(nir_shader *shader, nir_opt_licm_filter_instr_cb filter_instr) { - /* TODO: This is deprecated because nir_instr_can_speculate is a better way - * to handle speculative execution. - * - * By only visiting blocks which dominate the block after the loop, - * we ensure that we don't speculatively hoist any instructions - * which otherwise might not be executed. - */ - return nir_block_dominates(block, nir_loop_successor_block(loop)); -} - -bool -nir_opt_licm(nir_shader *shader, nir_opt_licm_filter_block_cb filter_block, - nir_opt_licm_filter_instr_cb filter_instr) -{ - licm_state state = {filter_block, filter_instr}; + licm_state state = {filter_instr}; bool progress = false; nir_foreach_function_impl(impl, shader) { diff --git a/src/compiler/nir/tests/opt_licm_tests.cpp b/src/compiler/nir/tests/opt_licm_tests.cpp index f669f48dd8d..f8b70394f3a 100644 --- a/src/compiler/nir/tests/opt_licm_tests.cpp +++ b/src/compiler/nir/tests/opt_licm_tests.cpp @@ -51,7 +51,7 @@ nir_opt_licm_test::test_finish(nir_opt_licm_filter_instr_cb filter_instr) nir_validate_shader(b->shader, NULL); bool progress = false; - NIR_PASS(progress, b->shader, nir_opt_licm, NULL, filter_instr); + NIR_PASS(progress, b->shader, nir_opt_licm, filter_instr); if (expect_progress) { ASSERT_TRUE(progress); diff --git a/src/imagination/pco/pco_nir.c b/src/imagination/pco/pco_nir.c index 46016319423..3ccd9d1adf7 100644 --- a/src/imagination/pco/pco_nir.c +++ b/src/imagination/pco/pco_nir.c @@ -788,6 +788,14 @@ static bool robustness_filter(const nir_intrinsic_instr *intr, return false; } +static bool +opt_licm_filter_instr_cb(nir_instr *instr, bool instr_dominates_exit, + unsigned num_dst_bits, unsigned num_all_src_bits, + nir_loop *loop) +{ + return instr_dominates_exit; +} + /** * \brief Lowers a NIR shader. * @@ -808,7 +816,7 @@ void pco_lower_nir(pco_ctx *ctx, nir_shader *nir, pco_data *data) NIR_PASS(_, nir, nir_lower_memory_model); - NIR_PASS(_, nir, nir_opt_licm, nir_opt_licm_filter_blocks_dominating_exit, NULL); + NIR_PASS(_, nir, nir_opt_licm, opt_licm_filter_instr_cb); NIR_PASS(_, nir, nir_lower_memcpy);