From: Vasily Khoruzhick Date: Tue, 10 Mar 2020 02:34:43 +0000 (-0700) Subject: lima/gpir: kill dead writes to regs in DCE X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b7d89476f1e7d0f3b9e751887f42b750a5ec216e;p=mesa.git 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 Signed-off-by: Vasily Khoruzhick Tested-by: Marge Bot Part-of: --- diff --git a/.gitlab-ci/deqp-lima-fails.txt b/.gitlab-ci/deqp-lima-fails.txt index 10915b9745a..c6d1cf56ecd 100644 --- a/.gitlab-ci/deqp-lima-fails.txt +++ b/.gitlab-ci/deqp-lima-fails.txt @@ -69,19 +69,9 @@ dEQP-GLES2.functional.shaders.functions.qualifiers.inout_lowp_int_vertex dEQP-GLES2.functional.shaders.functions.qualifiers.out_highp_int_vertex dEQP-GLES2.functional.shaders.functions.qualifiers.out_int_vertex dEQP-GLES2.functional.shaders.functions.qualifiers.out_lowp_int_vertex -dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat3_dynamic_loop_write_static_loop_read_vertex -dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat3_dynamic_loop_write_static_read_vertex -dEQP-GLES2.functional.shaders.indexing.matrix_subscript.mat3_dynamic_write_dynamic_loop_read_vertex -dEQP-GLES2.functional.shaders.loops.do_while_constant_iterations.conditional_body_vertex dEQP-GLES2.functional.shaders.loops.do_while_dynamic_iterations.vector_counter_fragment -dEQP-GLES2.functional.shaders.loops.do_while_uniform_iterations.conditional_body_vertex -dEQP-GLES2.functional.shaders.loops.do_while_uniform_iterations.nested_tricky_dataflow_2_vertex dEQP-GLES2.functional.shaders.loops.for_dynamic_iterations.vector_counter_fragment -dEQP-GLES2.functional.shaders.loops.while_constant_iterations.compound_statement_vertex -dEQP-GLES2.functional.shaders.loops.while_constant_iterations.sequence_statement_vertex -dEQP-GLES2.functional.shaders.loops.while_dynamic_iterations.nested_sequence_vertex dEQP-GLES2.functional.shaders.loops.while_dynamic_iterations.vector_counter_fragment -dEQP-GLES2.functional.shaders.loops.while_uniform_iterations.nested_vertex dEQP-GLES2.functional.shaders.operator.binary_operator.sub_assign_effect.highp_int_vertex dEQP-GLES2.functional.shaders.operator.binary_operator.sub_assign_effect.highp_ivec2_int_vertex dEQP-GLES2.functional.shaders.operator.binary_operator.sub_assign_effect.highp_ivec2_vertex diff --git a/.gitlab-ci/deqp-lima-skips.txt b/.gitlab-ci/deqp-lima-skips.txt index 0ee0188885e..83b241f34d1 100644 --- a/.gitlab-ci/deqp-lima-skips.txt +++ b/.gitlab-ci/deqp-lima-skips.txt @@ -26,18 +26,11 @@ dEQP-GLES2.functional.shaders.random.all_features.fragment.55 dEQP-GLES2.functional.shaders.random.trigonometric.fragment.1 dEQP-GLES2.functional.shaders.random.trigonometric.fragment.69 -# Driver bugs causing GPU errors -dEQP-GLES2.functional.shaders.loops.while_constant_iterations.nested_sequence_vertex -dEQP-GLES2.functional.shaders.loops.while_constant_iterations.conditional_body_vertex -dEQP-GLES2.functional.shaders.loops.while_uniform_iterations.conditional_continue_vertex -dEQP-GLES2.functional.shaders.loops.while_uniform_iterations.double_continue_vertex - # Hangs / OOM dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_static_read dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_dynamic_read dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_static_loop_read dEQP-GLES2.functional.shaders.indexing.varying_array.vec4_dynamic_loop_write_dynamic_loop_read -dEQP-GLES2.functional.shaders.indexing.tmp_array.vec3_dynamic_loop_write_dynamic_read_vertex dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_dynamic_loop_write_static_read_vertex dEQP-GLES2.functional.shaders.indexing.tmp_array.vec4_dynamic_loop_write_dynamic_read_vertex 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