Mesa (master): lima/ppir: do not assume single src for pipeline outputs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 9 11:46:09 UTC 2020


Module: Mesa
Branch: master
Commit: c6a3987f320fa26fa88e6d86cf236d7e426aab84
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c6a3987f320fa26fa88e6d86cf236d7e426aab84

Author: Erico Nunes <nunes.erico at gmail.com>
Date:   Mon Apr 13 15:24:35 2020 +0200

lima/ppir: do not assume single src for pipeline outputs

Even if a node has pipeline output and a single successor, it is still
valid for that successor to have multiple references to that pipeline
node. A trivial example is add(u.x,u.y) where u is a uniform.
It is even possible for this to occur with consts as operands of fcsel.
So remove uses of ppir_node_get_src_for_pred as that would assume a
single src in the node that uses the pipeline.

Signed-off-by: Erico Nunes <nunes.erico at gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4535>

---

 src/gallium/drivers/lima/ir/pp/lower.c         | 28 ++++++++++++++++++--------
 src/gallium/drivers/lima/ir/pp/node_to_instr.c | 15 ++++++++++----
 src/gallium/drivers/lima/ir/pp/ppir.h          | 11 ----------
 3 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c
index f7c61df2b0a..b5b7c34c25f 100644
--- a/src/gallium/drivers/lima/ir/pp/lower.c
+++ b/src/gallium/drivers/lima/ir/pp/lower.c
@@ -37,17 +37,24 @@ static bool ppir_lower_const(ppir_block *block, ppir_node *node)
    assert(ppir_node_has_single_succ(node));
 
    ppir_node *succ = ppir_node_first_succ(node);
-   ppir_src *src = ppir_node_get_src_for_pred(succ, node);
    ppir_dest *dest = ppir_node_get_dest(node);
-   assert(src != NULL);
 
    switch (succ->type) {
    case ppir_node_type_alu:
    case ppir_node_type_branch:
       /* ALU and branch can consume consts directly */
-      dest->type = src->type = ppir_target_pipeline;
+      dest->type = ppir_target_pipeline;
       /* Reg will be updated in node_to_instr later */
-      dest->pipeline = src->pipeline = ppir_pipeline_reg_const0;
+      dest->pipeline = ppir_pipeline_reg_const0;
+
+      /* single succ can still have multiple references to this node */
+      for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
+         ppir_src *src = ppir_node_get_src(succ, i);
+         if (src && src->node == node) {
+            src->type = ppir_target_pipeline;
+            src->pipeline = ppir_pipeline_reg_const0;
+         }
+      }
       return true;
    default:
       /* Create a move for everyone else */
@@ -105,10 +112,15 @@ static bool ppir_lower_load(ppir_block *block, ppir_node *node)
       switch (succ->type) {
       case ppir_node_type_alu:
       case ppir_node_type_branch: {
-         ppir_src *src = ppir_node_get_src_for_pred(succ, node);
-         /* Can consume uniforms directly */
-         src->type = dest->type = ppir_target_pipeline;
-         src->pipeline = dest->pipeline = ppir_pipeline_reg_uniform;
+         /* single succ can still have multiple references to this node */
+         for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
+            ppir_src *src = ppir_node_get_src(succ, i);
+            if (src && src->node == node) {
+               /* Can consume uniforms directly */
+               src->type = dest->type = ppir_target_pipeline;
+               src->pipeline = dest->pipeline = ppir_pipeline_reg_uniform;
+            }
+         }
          return true;
       }
       default:
diff --git a/src/gallium/drivers/lima/ir/pp/node_to_instr.c b/src/gallium/drivers/lima/ir/pp/node_to_instr.c
index eb472b5f0f8..9882951db46 100644
--- a/src/gallium/drivers/lima/ir/pp/node_to_instr.c
+++ b/src/gallium/drivers/lima/ir/pp/node_to_instr.c
@@ -123,10 +123,17 @@ static bool ppir_do_one_node_to_instr(ppir_block *block, ppir_node *node, ppir_n
 
       /* Turn dest back to SSA, so we can update predecessors */
       ppir_node *succ = ppir_node_first_succ(node);
-      ppir_src *succ_src = ppir_node_get_src_for_pred(succ, node);
-      dest->type = ppir_target_ssa;
-      dest->ssa.index = -1;
-      ppir_node_target_assign(succ_src, node);
+
+      /* Single succ can still have multiple references to this node */
+      for (int i = 0; i < ppir_node_get_src_num(succ); i++) {
+         ppir_src *src = ppir_node_get_src(succ, i);
+         if (src && src->node == node) {
+            /* Can consume uniforms directly */
+            dest->type = ppir_target_ssa;
+            dest->ssa.index = -1;
+            ppir_node_target_assign(src, node);
+         }
+      }
 
       ppir_node *move = ppir_node_insert_mov(node);
       if (unlikely(!move))
diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h
index 6f2ff4090b4..dc76bfdc38a 100644
--- a/src/gallium/drivers/lima/ir/pp/ppir.h
+++ b/src/gallium/drivers/lima/ir/pp/ppir.h
@@ -550,17 +550,6 @@ static inline ppir_reg *ppir_dest_get_reg(ppir_dest *dest)
    }
 }
 
-static inline ppir_src *ppir_node_get_src_for_pred(ppir_node *node, ppir_node *pred)
-{
-   for (int i = 0; i < ppir_node_get_src_num(node); i++) {
-      ppir_src *src = ppir_node_get_src(node, i);
-      if (src && src->node == pred)
-         return src;
-   }
-
-   return NULL;
-}
-
 static inline void ppir_node_target_assign(ppir_src *src, ppir_node *node)
 {
    ppir_dest *dest = ppir_node_get_dest(node);



More information about the mesa-commit mailing list