diff options
author | Jason Ekstrand <[email protected]> | 2015-02-06 12:06:04 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-02-19 17:06:16 -0800 |
commit | b4c5489c8ac12eb2c9881ba2d8bb745203affb7b (patch) | |
tree | 4aa2bf29b4e43c97940d0e71f6d2081a123693c9 /src/glsl/nir/nir_dominance.c | |
parent | 6316c90cc0daa9e9476b00e3c52c51190e782c3f (diff) |
nir/dominance: Expose the dominance intersection function
Being able to find the least common anscestor in the dominance tree is a
useful thing that we may want to do in other passes. In particular, we
need it for GCM.
v2: Handle NULL inputs by returning the other block
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_dominance.c')
-rw-r--r-- | src/glsl/nir/nir_dominance.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_dominance.c b/src/glsl/nir/nir_dominance.c index 4927a292882..29589cbce23 100644 --- a/src/glsl/nir/nir_dominance.c +++ b/src/glsl/nir/nir_dominance.c @@ -212,6 +212,28 @@ nir_calc_dominance(nir_shader *shader) } } +/** + * Computes the least common anscestor of two blocks. If one of the blocks + * is null, the other block is returned. + */ +nir_block * +nir_dominance_lca(nir_block *b1, nir_block *b2) +{ + if (b1 == NULL) + return b2; + + if (b2 == NULL) + return b1; + + assert(nir_cf_node_get_function(&b1->cf_node) == + nir_cf_node_get_function(&b2->cf_node)); + + assert(nir_cf_node_get_function(&b1->cf_node)->valid_metadata & + nir_metadata_dominance); + + return intersect(b1, b2); +} + static bool dump_block_dom(nir_block *block, void *state) { |