mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 04:10:09 +01:00
nir/divergence: add nir_def_is_divergent_at_use_block helper
For cases where the block we are interested in is not the immediate block of the nir_src. Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38974>
This commit is contained in:
parent
a49c5c07e9
commit
4d8cc7d82e
2 changed files with 14 additions and 7 deletions
|
|
@ -1171,7 +1171,15 @@ nir_src_num_components(nir_src src)
|
|||
return src.ssa->num_components;
|
||||
}
|
||||
|
||||
bool nir_src_is_divergent(nir_src *src);
|
||||
nir_block *nir_src_get_block(nir_src *src);
|
||||
|
||||
bool nir_def_is_divergent_at_use_block(nir_def *def, nir_block *block);
|
||||
|
||||
static inline bool
|
||||
nir_src_is_divergent(nir_src *src)
|
||||
{
|
||||
return nir_def_is_divergent_at_use_block(src->ssa, nir_src_get_block(src));
|
||||
}
|
||||
|
||||
/* Are all components the same, ie. .xxxx */
|
||||
static inline bool
|
||||
|
|
@ -4536,7 +4544,6 @@ 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)
|
||||
|
|
|
|||
|
|
@ -68,13 +68,13 @@ static bool
|
|||
visit_cf_list(struct exec_list *list, struct divergence_state *state);
|
||||
|
||||
bool
|
||||
nir_src_is_divergent(nir_src *src)
|
||||
nir_def_is_divergent_at_use_block(nir_def *def, nir_block *block)
|
||||
{
|
||||
if (src->ssa->divergent)
|
||||
if (def->divergent)
|
||||
return true;
|
||||
|
||||
nir_cf_node *use_node = nir_src_get_block(src)->cf_node.parent;
|
||||
nir_cf_node *def_node = nir_def_block(src->ssa)->cf_node.parent;
|
||||
nir_cf_node *use_node = block->cf_node.parent;
|
||||
nir_cf_node *def_node = nir_def_block(def)->cf_node.parent;
|
||||
|
||||
/* Short-cut the common case. */
|
||||
if (def_node == use_node)
|
||||
|
|
@ -83,7 +83,7 @@ nir_src_is_divergent(nir_src *src)
|
|||
/* If the source was computed in a divergent loop, and is not
|
||||
* loop-invariant, then it must also be considered divergent.
|
||||
*/
|
||||
bool loop_invariant = src->ssa->loop_invariant;
|
||||
bool loop_invariant = def->loop_invariant;
|
||||
while (def_node) {
|
||||
if (def_node->type == nir_cf_node_loop) {
|
||||
/* Check whether the use is inside this loop. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue