lima/ppir: fix ordering deps
authorVasily Khoruzhick <anarsoul@gmail.com>
Mon, 19 Aug 2019 05:51:34 +0000 (22:51 -0700)
committerVasily Khoruzhick <anarsoul@gmail.com>
Sat, 24 Aug 2019 01:19:47 +0000 (18:19 -0700)
There can be several root nodes, i.e.:

(1) r0 = r1
(2) r2 = r3
(3) branch if (ssa1)

We need to make (3) depend on (1) and (2), old code added
dependency only for (2), and (1) was kept as root node since there
is no branch/discard or store color between two movs.

Tested-by: Andreas Baierl <ichgeh@imkreisrum.de>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Erico Nunes <nunes.erico@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
src/gallium/drivers/lima/ir/pp/nir.c

index d1a8bc140b69b715a7b8742ae1f9032014d56af8..f7eaccd7c63bda90f7555adeaabb636c4f04f8d2 100644 (file)
@@ -576,12 +576,14 @@ static void ppir_add_ordering_deps(ppir_compiler *comp)
     */
    list_for_each_entry(ppir_block, block, &comp->block_list, list) {
       ppir_node *prev_node = NULL;
-      list_for_each_entry(ppir_node, node, &block->node_list, list) {
-         if (node->type == ppir_node_type_discard ||
-             node->type == ppir_node_type_store ||
-             node->type == ppir_node_type_branch) {
-            if (prev_node)
-               ppir_node_add_dep(node, prev_node);
+      list_for_each_entry_rev(ppir_node, node, &block->node_list, list) {
+         if (prev_node && ppir_node_is_root(node) && node->op != ppir_op_const) {
+            ppir_node_add_dep(prev_node, node);
+         }
+         if (node->op == ppir_op_discard ||
+             node->op == ppir_op_store_color ||
+             node->op == ppir_op_store_temp ||
+             node->op == ppir_op_branch) {
             prev_node = node;
          }
       }