nir/unsigned_upper_bound: don't require dominance metadata

Instead, determine if it's a merge or loop exit phi.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9808>
This commit is contained in:
Rhys Perry 2021-03-24 14:56:48 +00:00 committed by Marge Bot
parent aebffc241d
commit 49add985ff
3 changed files with 3 additions and 14 deletions

View file

@ -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");

View file

@ -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};

View file

@ -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);