From bb7e8d51b64723522541cbb5cd9ecac79cf2ee27 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 4 Sep 2024 22:04:12 +0200 Subject: [PATCH] nir: delete nir_opt_reuse_constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/meson.build | 1 - src/compiler/nir/nir.h | 2 - src/compiler/nir/nir_opt_reuse_constants.c | 51 ---------------------- 3 files changed, 54 deletions(-) delete mode 100644 src/compiler/nir/nir_opt_reuse_constants.c diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build index 3ba61c45c3c..68ac325a7b7 100644 --- a/src/compiler/nir/meson.build +++ b/src/compiler/nir/meson.build @@ -253,7 +253,6 @@ files_libnir = files( 'nir_opt_reassociate_bfi.c', 'nir_opt_rematerialize_compares.c', 'nir_opt_remove_phis.c', - 'nir_opt_reuse_constants.c', 'nir_opt_shrink_stores.c', 'nir_opt_shrink_vectors.c', 'nir_opt_sink.c', diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 2854d514ea5..2e1f011a571 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -6845,8 +6845,6 @@ bool nir_opt_ray_queries(nir_shader *shader); bool nir_opt_ray_query_ranges(nir_shader *shader); -bool nir_opt_reuse_constants(nir_shader *shader); - void nir_sweep(nir_shader *shader); void nir_remap_dual_slot_attributes(nir_shader *shader, diff --git a/src/compiler/nir/nir_opt_reuse_constants.c b/src/compiler/nir/nir_opt_reuse_constants.c deleted file mode 100644 index 8e78a6cc0c1..00000000000 --- a/src/compiler/nir/nir_opt_reuse_constants.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2023 Intel Corporation - * SPDX-License-Identifier: MIT - */ - -#include "nir.h" -#include "nir_instr_set.h" - -bool -nir_opt_reuse_constants(nir_shader *shader) -{ - bool progress = false; - - struct set *consts = nir_instr_set_create(NULL); - nir_foreach_function_impl(impl, shader) { - _mesa_set_clear(consts, NULL); - - nir_block *start_block = nir_start_block(impl); - bool func_progress = false; - - nir_foreach_block_safe(block, impl) { - const bool in_start_block = start_block == block; - nir_foreach_instr_safe(instr, block) { - if (instr->type != nir_instr_type_load_const) - continue; - - struct set_entry *entry = _mesa_set_search(consts, instr); - if (!entry) { - if (!in_start_block) - nir_instr_move(nir_after_block_before_jump(start_block), instr); - _mesa_set_add(consts, instr); - } - - if (nir_instr_set_add_or_rewrite(consts, instr, nir_instrs_equal)) { - func_progress = true; - nir_instr_remove(instr); - } - } - } - - if (func_progress) { - nir_metadata_preserve(impl, nir_metadata_control_flow); - progress = true; - } else { - nir_metadata_preserve(impl, nir_metadata_all); - } - } - - nir_instr_set_destroy(consts); - return progress; -}