diff options
author | Jason Ekstrand <[email protected]> | 2015-02-06 12:45:43 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-02-19 17:06:17 -0800 |
commit | f481a9425cb8d70bc61c6303268a465f5a05896b (patch) | |
tree | 5045a7422e40089ff9036b774d60b7814a12bd5b /src/glsl/nir/nir.h | |
parent | b4c5489c8ac12eb2c9881ba2d8bb745203affb7b (diff) |
nir/dominance: Add a constant-time mechanism for comparing blocks
This is mostly thanks to Connor. The idea is to do a depth-first search
that computes pre and post indices for all the blocks. We can then figure
out if one block dominates another in constant time by two simple
comparison operations.
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir.h')
-rw-r--r-- | src/glsl/nir/nir.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 0784218c0db..7f6e241f915 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1135,6 +1135,14 @@ typedef struct nir_block { /* Set of nir_block's on the dominance frontier of this block */ struct set *dom_frontier; + /* + * These two indices have the property that dom_{pre,post}_index for each + * child of this block in the dominance tree will always be between + * dom_pre_index and dom_post_index for this block, which makes testing if + * a given block is dominated by another block an O(1) operation. + */ + unsigned dom_pre_index, dom_post_index; + /* live in and out for this block; used for liveness analysis */ BITSET_WORD *live_in; BITSET_WORD *live_out; @@ -1518,6 +1526,7 @@ void nir_calc_dominance_impl(nir_function_impl *impl); void nir_calc_dominance(nir_shader *shader); nir_block *nir_dominance_lca(nir_block *b1, nir_block *b2); +bool nir_block_dominates(nir_block *parent, nir_block *child); void nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp); void nir_dump_dom_tree(nir_shader *shader, FILE *fp); |