lima/gpir: kill dead writes to regs in DCE
authorVasily Khoruzhick <anarsoul@gmail.com>
Tue, 10 Mar 2020 02:34:43 +0000 (19:34 -0700)
committerMarge Bot <eric+marge@anholt.net>
Mon, 16 Mar 2020 23:08:06 +0000 (23:08 +0000)
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 <ichgeh@imkreisrum.de>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4125>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4125>

.gitlab-ci/deqp-lima-fails.txt
.gitlab-ci/deqp-lima-skips.txt
src/gallium/drivers/lima/ir/gp/optimize.c

index 10915b9745acd86273ce3c559a7a4e038304f724..c6d1cf56ecd3569dd5842831263e8ca2670e10bc 100644 (file)
@@ -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
index 0ee0188885eec576b0cfcd0e5eb2b46ec1370371..83b241f34d1fdbc440c088fe370699e5e45b0fb1 100644 (file)
@@ -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
index afa10ec05140741dfc1fe80439a23952d72b9565..c95faec9c6d5af37780aeb35830556b34a0cd921 100644 (file)
@@ -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