Commit cc5d383f authored by Jesse Natalie's avatar Jesse Natalie Committed by Erik Faye-Lund
Browse files

nir_dominance: Use uint32_t instead of int16_t for dominance counters

We're seeing OpenCL kernels that can hit this INT16_MAX block count.
parent 2813fc0e
......@@ -2466,7 +2466,7 @@ typedef struct nir_block {
* 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;
/* live in and out for this block; used for liveness analysis */
BITSET_WORD *live_in;
......@@ -2477,7 +2477,7 @@ static inline bool
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 *
......
......@@ -43,8 +43,8 @@ init_block(nir_block *block, nir_function_impl *impl)
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);
......@@ -153,6 +153,9 @@ calc_dom_children(nir_function_impl* impl)
static void
calc_dfs_indicies(nir_block *block, unsigned *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++)
......@@ -192,7 +195,7 @@ nir_calc_dominance_impl(nir_function_impl *impl)
calc_dom_children(impl);
unsigned dfs_index = 0;
unsigned dfs_index = 1;
calc_dfs_indicies(start_block, &dfs_index);
}
......@@ -254,8 +257,8 @@ nir_block_dominates(nir_block *parent, nir_block *child)
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 &&
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment