pan/bi: Set back-to-back bit more accurately
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 28 May 2020 18:13:12 +0000 (14:13 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 May 2020 20:34:55 +0000 (20:34 +0000)
See Connor's ISA notes. Basically set unless it's a branch (explicit or
fallthrough).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5260>

src/panfrost/bifrost/bi_schedule.c

index 47444b87ce05df378a8432cc0bc8e65dcd9e02b0..0e0df05f2938c19edadea0d253211342eec49e29 100644 (file)
@@ -133,6 +133,31 @@ bi_lower_fmov(bi_instruction *ins)
         ins->src_types[1] = ins->src_types[0];
 }
 
+/* To work out the back-to-back flag, we need to detect branches and
+ * "fallthrough" branches, implied in the last clause of a block that falls
+ * through to another block with *multiple predecessors*. */
+
+static bool
+bi_back_to_back(bi_block *block)
+{
+        /* Last block of a program */
+        if (!block->base.successors[0]) {
+                assert(!block->base.successors[1]);
+                return false;
+        }
+
+        /* Multiple successors? We're branching */
+        if (block->base.successors[1])
+                return false;
+
+        struct pan_block *succ = block->base.successors[0];
+        assert(succ->predecessors);
+        unsigned count = succ->predecessors->entries;
+
+        /* Back to back only if the successor has only a single predecessor */
+        return (count == 1);
+}
+
 /* Eventually, we'll need a proper scheduling, grouping instructions
  * into clauses and ordering/assigning grouped instructions to the
  * appropriate FMA/ADD slots. Right now we do the dumbest possible
@@ -194,7 +219,9 @@ bi_schedule(bi_context *ctx)
 
                         ids = ids & 1;
                         last_id = u->scoreboard_id;
-                        u->back_to_back = false;
+
+                        /* Let's be optimistic, we'll fix up later */
+                        u->back_to_back = true;
 
                         u->constant_count = 1;
                         u->constants[0] = ins->constant.u64;
@@ -209,6 +236,13 @@ bi_schedule(bi_context *ctx)
                         list_addtail(&u->link, &bblock->clauses);
                 }
 
+                /* Back-to-back bit affects only the last clause of a block,
+                 * the rest are implicitly true */
+                bi_clause *last_clause = list_last_entry(&bblock->clauses, bi_clause, link);
+
+                if (last_clause)
+                        last_clause->back_to_back = bi_back_to_back(bblock);
+
                 bblock->scheduled = true;
         }
 }