From 49add985ffbfdc44d5865f04ebcb05dbabb88a51 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 24 Mar 2021 14:56:48 +0000 Subject: [PATCH] nir/unsigned_upper_bound: don't require dominance metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead, determine if it's a merge or loop exit phi. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_instruction_selection_setup.cpp | 4 +--- src/compiler/nir/nir_opt_offsets.c | 3 --- src/compiler/nir/nir_range_analysis.c | 10 ++-------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp index ba36c56e9a3..ba64a736a57 100644 --- a/src/amd/compiler/aco_instruction_selection_setup.cpp +++ b/src/amd/compiler/aco_instruction_selection_setup.cpp @@ -303,8 +303,6 @@ void apply_nuw_to_ssa(isel_context *ctx, nir_ssa_def *ssa) void apply_nuw_to_offsets(isel_context *ctx, nir_function_impl *impl) { - nir_metadata_require(impl, nir_metadata_dominance); - nir_foreach_block(block, impl) { nir_foreach_instr(instr, block) { if (instr->type != nir_instr_type_intrinsic) @@ -594,7 +592,7 @@ void init_context(isel_context *ctx, nir_shader *shader) nir_metadata_preserve(impl, nir_metadata_none); /* we'll need these for isel */ - nir_metadata_require(impl, nir_metadata_block_index | nir_metadata_dominance); + nir_metadata_require(impl, nir_metadata_block_index); if (!ctx->stage.has(SWStage::GSCopy) && ctx->options->dump_preoptir) { fprintf(stderr, "NIR shader before instruction selection:\n"); diff --git a/src/compiler/nir/nir_opt_offsets.c b/src/compiler/nir/nir_opt_offsets.c index 4047ee5daae..88b7b2a2862 100644 --- a/src/compiler/nir/nir_opt_offsets.c +++ b/src/compiler/nir/nir_opt_offsets.c @@ -51,9 +51,6 @@ try_extract_const_addition(nir_builder *b, nir_instr *instr, opt_offsets_state * state->range_ht = _mesa_pointer_hash_table_create(NULL); } - /* Dominance metadata is needed by nir_unsigned_upper_bound to chase phis */ - nir_metadata_require(b->impl, nir_metadata_dominance); - /* Check if there can really be an unsigned wrap. */ nir_ssa_scalar src0 = {alu->src[0].src.ssa, 0}; nir_ssa_scalar src1 = {alu->src[1].src.ssa, 0}; diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index 1d7eb99283e..6936b49c9de 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -1402,16 +1402,10 @@ nir_unsigned_upper_bound(nir_shader *shader, struct hash_table *range_ht, } if (scalar.def->parent_instr->type == nir_instr_type_phi) { - bool cyclic = false; - nir_foreach_phi_src(src, nir_instr_as_phi(scalar.def->parent_instr)) { - if (nir_block_dominates(scalar.def->parent_instr->block, src->pred)) { - cyclic = true; - break; - } - } + nir_cf_node *prev = nir_cf_node_prev(&scalar.def->parent_instr->block->cf_node); uint32_t res = 0; - if (cyclic) { + if (!prev || prev->type == nir_cf_node_block) { _mesa_hash_table_insert(range_ht, key, (void*)(uintptr_t)max); struct set *visited = _mesa_pointer_set_create(NULL);