freedreno/ir3: fix grouping issue w/ reverse swizzles
authorRob Clark <robclark@freedesktop.org>
Mon, 18 Apr 2016 15:32:40 +0000 (11:32 -0400)
committerRob Clark <robclark@freedesktop.org>
Mon, 18 Apr 2016 19:41:32 +0000 (15:41 -0400)
When we have something like:

   MOV OUT[n], IN[m].wzyx

the existing grouping code was missing a potential conflict.  Due to
input needing to be sequential scalar regs, we have:

 IN:  x <-> y <-> z <-> w

which would be grouped to:

 OUT: w <-> z2 <-> y2 <-> x  (where the 2 denotes a copy/mov)

but that can't actually work.  We need to realize that x and w are
already in the same chain, not just that they aren't both already in
new chain being built.

With this fixed, we probably no longer need the hack from f68f6c0.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/ir3/ir3_group.c

index cd59080b0f1c4555fc39dcf81a29f34407cd0043..f229fe6eecd09befe4309badad00898edbe4aee6 100644 (file)
@@ -90,6 +90,22 @@ instr_insert_mov(void *arr, int idx, struct ir3_instruction *instr)
 }
 static struct group_ops instr_ops = { instr_get, instr_insert_mov };
 
+/* verify that cur != instr, but cur is also not in instr's neighbor-list: */
+static bool
+in_neighbor_list(struct ir3_instruction *instr, struct ir3_instruction *cur)
+{
+       if (!instr)
+               return false;
+
+       if (instr == cur)
+               return true;
+
+       for (instr = ir3_neighbor_first(instr); instr; instr = instr->cp.right)
+               if (instr == cur)
+                       return true;
+
+       return false;
+}
 
 static void
 group_n(struct group_ops *ops, void *arr, unsigned n)
@@ -121,7 +137,7 @@ restart:
 
                        /* we also can't have an instr twice in the group: */
                        for (j = i + 1; (j < n) && !conflict; j++)
-                               if (ops->get(arr, j) == instr)
+                               if (in_neighbor_list(ops->get(arr, j), instr))
                                        conflict = true;
 
                        if (conflict) {