diff options
author | Vasily Khoruzhick <[email protected]> | 2020-03-09 19:34:43 -0700 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-16 23:08:06 +0000 |
commit | b7d89476f1e7d0f3b9e751887f42b750a5ec216e (patch) | |
tree | a17d6287aaf020e79902fef1e74682711087ae03 /src/gallium | |
parent | 8c1bcc8555ab17a1df043ebc8c2a3ebcf6c400bc (diff) |
lima/gpir: kill dead writes to regs in DCE
Writes to regs that are never read will confuse regalloc since they
are never live and don't conflict with any regs. Kill them to prevent
overwriting another live reg.
Reviewed-by: Andreas Baierl <[email protected]>
Signed-off-by: Vasily Khoruzhick <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4125>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4125>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/lima/ir/gp/optimize.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/lima/ir/gp/optimize.c b/src/gallium/drivers/lima/ir/gp/optimize.c index afa10ec0514..c95faec9c6d 100644 --- a/src/gallium/drivers/lima/ir/gp/optimize.c +++ b/src/gallium/drivers/lima/ir/gp/optimize.c @@ -171,6 +171,34 @@ dead_code_eliminate(gpir_compiler *comp) } } } + + /* Kill all the writes to regs that are never read. All the known + * instances of these are coming from the cycle-breaking register + * created in out-of-SSA. See resolve_parallel_copy() in nir_from_ssa.c + * Since we kill redundant movs when we translate nir into gpir, it + * results in this reg being written, but never read. + */ + BITSET_WORD *regs = rzalloc_array(comp, BITSET_WORD, comp->cur_reg); + list_for_each_entry(gpir_block, block, &comp->block_list, list) { + list_for_each_entry(gpir_node, node, &block->node_list, list) { + if (node->op != gpir_op_load_reg) + continue; + gpir_load_node *load = gpir_node_to_load(node); + BITSET_SET(regs, load->reg->index); + } + } + + list_for_each_entry(gpir_block, block, &comp->block_list, list) { + list_for_each_entry_safe(gpir_node, node, &block->node_list, list) { + if (node->op != gpir_op_store_reg) + continue; + gpir_store_node *store = gpir_node_to_store(node); + if (!BITSET_TEST(regs, store->reg->index)) + gpir_node_delete(node); + } + } + + ralloc_free(regs); } bool |