nir: add nir_block *nir_src_get_block(src) helper
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7710>
This commit is contained in:

committed by
Marge Bot

parent
12ff1b683e
commit
50d416fe89
@@ -1480,6 +1480,17 @@ nir_src_is_always_uniform(nir_src src)
|
||||
return false;
|
||||
}
|
||||
|
||||
nir_block *
|
||||
nir_src_get_block(nir_src *src)
|
||||
{
|
||||
if (nir_src_is_if(src))
|
||||
return nir_cf_node_cf_tree_prev(&nir_src_parent_if(src)->cf_node);
|
||||
else if (nir_src_parent_instr(src)->type == nir_instr_type_phi)
|
||||
return list_entry(src, nir_phi_src, src)->pred;
|
||||
else
|
||||
return nir_src_parent_instr(src)->block;
|
||||
}
|
||||
|
||||
static void
|
||||
src_remove_all_uses(nir_src *src)
|
||||
{
|
||||
|
@@ -4943,6 +4943,7 @@ const char *nir_src_as_string(nir_src src);
|
||||
bool nir_src_is_always_uniform(nir_src src);
|
||||
bool nir_srcs_equal(nir_src src1, nir_src src2);
|
||||
bool nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2);
|
||||
nir_block *nir_src_get_block(nir_src *src);
|
||||
|
||||
static inline void
|
||||
nir_src_rewrite(nir_src *src, nir_def *new_ssa)
|
||||
|
@@ -200,34 +200,7 @@ get_preferred_block(nir_def *def, bool sink_out_of_loops)
|
||||
nir_block *lca = NULL;
|
||||
|
||||
nir_foreach_use_including_if(use, def) {
|
||||
nir_block *use_block;
|
||||
|
||||
if (nir_src_is_if(use)) {
|
||||
use_block =
|
||||
nir_cf_node_as_block(nir_cf_node_prev(&nir_src_parent_if(use)->cf_node));
|
||||
} else {
|
||||
nir_instr *instr = nir_src_parent_instr(use);
|
||||
use_block = instr->block;
|
||||
|
||||
/*
|
||||
* Kind of an ugly special-case, but phi instructions
|
||||
* need to appear first in the block, so by definition
|
||||
* we can't move an instruction into a block where it is
|
||||
* consumed by a phi instruction. We could conceivably
|
||||
* move it into a dominator block.
|
||||
*/
|
||||
if (instr->type == nir_instr_type_phi) {
|
||||
nir_phi_instr *phi = nir_instr_as_phi(instr);
|
||||
nir_block *phi_lca = NULL;
|
||||
nir_foreach_phi_src(src, phi) {
|
||||
if (&src->src == use)
|
||||
phi_lca = nir_dominance_lca(phi_lca, src->pred);
|
||||
}
|
||||
use_block = phi_lca;
|
||||
}
|
||||
}
|
||||
|
||||
lca = nir_dominance_lca(lca, use_block);
|
||||
lca = nir_dominance_lca(lca, nir_src_get_block(use));
|
||||
}
|
||||
|
||||
/* return in case, we didn't find a reachable user */
|
||||
|
Reference in New Issue
Block a user