lima: ppir: always create move and update ld_tex successors for all blocks
authorVasily Khoruzhick <anarsoul@gmail.com>
Sat, 25 Jan 2020 21:31:53 +0000 (13:31 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 28 Jan 2020 01:45:29 +0000 (01:45 +0000)
Always create a mov for ld_tex since we can't rely on
ppir_node_has_single_src_succ() if we have multiple blocks. And since
ld_tex successor can be in a different block we have to update their
ppir_src as well.

Reviewed-by: Erico Nunes <nunes.erico@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3564>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3564>

src/gallium/drivers/lima/ir/pp/lower.c
src/gallium/drivers/lima/ir/pp/node.c
src/gallium/drivers/lima/ir/pp/ppir.h

index 034425c97a7f9cf4821d65cbad23132419949259..f7c61df2b0ab533d4999ff9bc10c19b979443bab 100644 (file)
@@ -185,29 +185,8 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node)
    load_tex->src[0].type = load->dest.type = ppir_target_pipeline;
    load_tex->src[0].pipeline = load->dest.pipeline = ppir_pipeline_reg_discard;
 
-   if (ppir_node_has_single_src_succ(node)) {
-      ppir_node *succ = ppir_node_first_succ(node);
-      switch (succ->type) {
-      case ppir_node_type_alu:
-      case ppir_node_type_branch: {
-         for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
-            ppir_src *src = ppir_node_get_src(succ, i);
-            if (src->node == node) {
-               /* Can consume samplers directly */
-               src->type = dest->type = ppir_target_pipeline;
-               src->pipeline = dest->pipeline = ppir_pipeline_reg_sampler;
-            }
-         }
-         return true;
-      }
-      default:
-         /* Create mov for everyone else */
-         break;
-      }
-   }
-
-   /* Create move node */
-   ppir_node *move = ppir_node_insert_mov(node);
+   /* Always create move node since there can be successors in other blocks */
+   ppir_node *move = ppir_node_insert_mov_all_blocks(node);
    if (unlikely(!move))
       return false;
 
index e646a395ca7c8b28934d2c570649630240120c79..1a822b8903208e034c0d400838a8e974ff4fffc5 100644 (file)
@@ -732,6 +732,27 @@ ppir_node *ppir_node_insert_mov(ppir_node *node)
    return move;
 }
 
+ppir_node *ppir_node_insert_mov_all_blocks(ppir_node *old)
+{
+   ppir_node *move = ppir_node_insert_mov(old);
+   ppir_compiler *comp = old->block->comp;
+
+   list_for_each_entry(ppir_block, block, &comp->block_list, list) {
+      if (old->block == block)
+         continue;
+      list_for_each_entry_safe(ppir_node, node, &block->node_list, list) {
+         for (int i = 0; i < ppir_node_get_src_num(node); i++){
+            ppir_src *src = ppir_node_get_src(node, i);
+            if (!src)
+               continue;
+            if (src->node == old)
+               ppir_node_target_assign(src, move);
+         }
+      }
+   }
+
+   return move;
+}
 bool ppir_node_has_single_src_succ(ppir_node *node)
 {
    if (list_is_singular(&node->succ_list) &&
index 2b4629bcaabf9cb33b268bfa9976daa16d732c07..357fcada8b79eb18f1f21ab1b69ae472a800dbfb 100644 (file)
@@ -412,6 +412,7 @@ ppir_dep *ppir_dep_for_pred(ppir_node *node, ppir_node *pred);
 ppir_node *ppir_node_clone(ppir_block *block, ppir_node *node);
 /* Assumes that node successors are in the same block */
 ppir_node *ppir_node_insert_mov(ppir_node *node);
+ppir_node *ppir_node_insert_mov_all_blocks(ppir_node *node);
 
 static inline bool ppir_node_is_root(ppir_node *node)
 {