* 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.
*/
- int16_t dom_pre_index, dom_post_index;
+ uint32_t dom_pre_index, dom_post_index;
/* SSA def live in and out for this block; used for liveness analysis.
* Indexed by ssa_def->index
nir_block_is_reachable(nir_block *b)
{
/* See also nir_block_dominates */
- return b->dom_post_index != -1;
+ return b->dom_post_index != 0;
}
static inline nir_instr *
block->num_dom_children = 0;
/* See nir_block_dominates */
- block->dom_pre_index = INT16_MAX;
- block->dom_post_index = -1;
+ block->dom_pre_index = UINT32_MAX;
+ block->dom_post_index = 0;
set_foreach(block->dom_frontier, entry) {
_mesa_set_remove(block->dom_frontier, entry);
}
static void
-calc_dfs_indicies(nir_block *block, unsigned *index)
+calc_dfs_indicies(nir_block *block, uint32_t *index)
{
+ /* UINT32_MAX has special meaning. See nir_block_dominates. */
+ assert(*index < UINT32_MAX - 2);
+
block->dom_pre_index = (*index)++;
for (unsigned i = 0; i < block->num_dom_children; i++)
calc_dom_children(impl);
- unsigned dfs_index = 0;
+ uint32_t dfs_index = 1;
calc_dfs_indicies(start_block, &dfs_index);
}
assert(nir_cf_node_get_function(&parent->cf_node)->valid_metadata &
nir_metadata_dominance);
- /* If a block is unreachable, then nir_block::dom_pre_index == INT16_MAX
- * and nir_block::dom_post_index == -1. This allows us to trivially handle
+ /* If a block is unreachable, then nir_block::dom_pre_index == UINT32_MAX
+ * and nir_block::dom_post_index == 0. This allows us to trivially handle
* unreachable blocks here with zero extra work.
*/
return child->dom_pre_index >= parent->dom_pre_index &&