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. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6657>
This commit is contained in:
@@ -2627,7 +2627,7 @@ typedef struct nir_block {
|
|||||||
* dom_pre_index and dom_post_index for this block, which makes testing if
|
* 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.
|
* 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.
|
/* SSA def live in and out for this block; used for liveness analysis.
|
||||||
* Indexed by ssa_def->index
|
* Indexed by ssa_def->index
|
||||||
@@ -2640,7 +2640,7 @@ static inline bool
|
|||||||
nir_block_is_reachable(nir_block *b)
|
nir_block_is_reachable(nir_block *b)
|
||||||
{
|
{
|
||||||
/* See also nir_block_dominates */
|
/* See also nir_block_dominates */
|
||||||
return b->dom_post_index != -1;
|
return b->dom_post_index != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline nir_instr *
|
static inline nir_instr *
|
||||||
|
@@ -43,8 +43,8 @@ init_block(nir_block *block, nir_function_impl *impl)
|
|||||||
block->num_dom_children = 0;
|
block->num_dom_children = 0;
|
||||||
|
|
||||||
/* See nir_block_dominates */
|
/* See nir_block_dominates */
|
||||||
block->dom_pre_index = INT16_MAX;
|
block->dom_pre_index = UINT32_MAX;
|
||||||
block->dom_post_index = -1;
|
block->dom_post_index = 0;
|
||||||
|
|
||||||
set_foreach(block->dom_frontier, entry) {
|
set_foreach(block->dom_frontier, entry) {
|
||||||
_mesa_set_remove(block->dom_frontier, entry);
|
_mesa_set_remove(block->dom_frontier, entry);
|
||||||
@@ -151,8 +151,11 @@ calc_dom_children(nir_function_impl* impl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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)++;
|
block->dom_pre_index = (*index)++;
|
||||||
|
|
||||||
for (unsigned i = 0; i < block->num_dom_children; i++)
|
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);
|
calc_dom_children(impl);
|
||||||
|
|
||||||
unsigned dfs_index = 0;
|
uint32_t dfs_index = 1;
|
||||||
calc_dfs_indicies(start_block, &dfs_index);
|
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 &
|
assert(nir_cf_node_get_function(&parent->cf_node)->valid_metadata &
|
||||||
nir_metadata_dominance);
|
nir_metadata_dominance);
|
||||||
|
|
||||||
/* If a block is unreachable, then nir_block::dom_pre_index == INT16_MAX
|
/* If a block is unreachable, then nir_block::dom_pre_index == UINT32_MAX
|
||||||
* and nir_block::dom_post_index == -1. This allows us to trivially handle
|
* and nir_block::dom_post_index == 0. This allows us to trivially handle
|
||||||
* unreachable blocks here with zero extra work.
|
* unreachable blocks here with zero extra work.
|
||||||
*/
|
*/
|
||||||
return child->dom_pre_index >= parent->dom_pre_index &&
|
return child->dom_pre_index >= parent->dom_pre_index &&
|
||||||
|
Reference in New Issue
Block a user