pan/midgard: Extend csel_swizzle to branches
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 24 Sep 2019 13:06:37 +0000 (09:06 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 30 Sep 2019 12:40:13 +0000 (08:40 -0400)
Conditions for branches don't have a swizzle explicitly in the emitted
binary, but they do implicitly get swizzled in whatever instruction
wrote r31, so we need to handle that.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/mir.c

index 780e432..60d5b9d 100644 (file)
@@ -88,8 +88,8 @@ typedef struct midgard_instruction {
         unsigned src[3];
         unsigned dest;
 
-        /* Swizzle for the conditional for a csel */
-        unsigned csel_swizzle;
+        /* Swizzle for the conditional for a csel/branch */
+        unsigned cond_swizzle;
 
         /* Special fields for an ALU instruction */
         midgard_reg_info registers;
index 95ec48e..337f46f 100644 (file)
@@ -1095,7 +1095,7 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
         };
 
         if (nr_inputs == 3) {
-                ins.csel_swizzle = SWIZZLE_FROM_ARRAY(nirmods[2]->swizzle);
+                ins.cond_swizzle = SWIZZLE_FROM_ARRAY(nirmods[2]->swizzle);
                 assert(!nirmods[2]->abs);
                 assert(!nirmods[2]->negate);
         }
index 9e5ba7a..faeac16 100644 (file)
@@ -42,8 +42,8 @@ unsigned
 mir_get_swizzle(midgard_instruction *ins, unsigned idx)
 {
         if (ins->type == TAG_ALU_4) {
-                if (idx == 2)
-                        return ins->csel_swizzle;
+                if (idx == 2 || ins->compact_branch)
+                        return ins->cond_swizzle;
 
                 unsigned b = (idx == 0) ? ins->alu.src1 : ins->alu.src2;
 
@@ -105,6 +105,11 @@ void
 mir_set_swizzle(midgard_instruction *ins, unsigned idx, unsigned new)
 {
         if (ins->type == TAG_ALU_4) {
+                if (idx == 2 || ins->compact_branch) {
+                        ins->cond_swizzle = new;
+                        return;
+                }
+
                 unsigned b = (idx == 0) ? ins->alu.src1 : ins->alu.src2;
 
                 midgard_vector_alu_src s =