pan/midgard: Allow inverted inverted ops
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 26 Feb 2020 18:50:46 +0000 (13:50 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 27 Feb 2020 21:02:35 +0000 (21:02 +0000)
We'd like to transform `inand.not` back to `iand` and so forth.

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

src/panfrost/midgard/midgard_opt_invert.c

index e11e4c0fdec2c74c1a10f29dc910630fb57843c0..b0ca4bd257f81d8ae1236243d675bc590fa019d9 100644 (file)
@@ -113,16 +113,35 @@ mir_is_bitwise(midgard_instruction *ins)
         }
 }
 
+static bool
+mir_is_inverted_bitwise(midgard_instruction *ins)
+{
+        switch (ins->alu.op) {
+        case midgard_alu_op_inand:
+        case midgard_alu_op_inor:
+        case midgard_alu_op_inxor:
+                return true;
+        default:
+                return false;
+        }
+}
+
 static midgard_alu_op
 mir_invert_op(midgard_alu_op op)
 {
         switch (op) {
         case midgard_alu_op_iand:
                 return midgard_alu_op_inand;
+        case midgard_alu_op_inand:
+                return midgard_alu_op_iand;
         case midgard_alu_op_ior:
                 return midgard_alu_op_inor;
+        case midgard_alu_op_inor:
+                return midgard_alu_op_ior;
         case midgard_alu_op_ixor:
                 return midgard_alu_op_inxor;
+        case midgard_alu_op_inxor:
+                return midgard_alu_op_ixor;
         default:
                 unreachable("Op not invertible");
         }
@@ -162,7 +181,7 @@ midgard_opt_fuse_dest_invert(compiler_context *ctx, midgard_block *block)
         mir_foreach_instr_in_block_safe(block, ins) {
                 /* Search for inverted bitwise */
                 if (ins->type != TAG_ALU_4) continue;
-                if (!mir_is_bitwise(ins)) continue;
+                if (!mir_is_bitwise(ins) && !mir_is_inverted_bitwise(ins)) continue;
                 if (!ins->invert) continue;
 
                 ins->alu.op = mir_invert_op(ins->alu.op);