pan/bi: Fuse conditions into discard_if
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 1 May 2020 22:36:42 +0000 (18:36 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 4 May 2020 15:08:15 +0000 (11:08 -0400)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4883>

src/panfrost/bifrost/bifrost_compile.c

index 3f68ae2ae0c5affa157ae13d8b000743cdb6118a..056d44718b3cbb6b45f8757e4dfe82a5fa30a12f 100644 (file)
@@ -365,6 +365,11 @@ bi_emit_discard(bi_context *ctx, nir_intrinsic_instr *instr)
         bi_emit(ctx, discard);
 }
 
+static void
+bi_fuse_cond(bi_instruction *csel, nir_alu_src cond,
+                unsigned *constants_left, unsigned *constant_shift,
+                unsigned comps, bool float_only);
+
 static void
 bi_emit_discard_if(bi_context *ctx, nir_intrinsic_instr *instr)
 {
@@ -381,6 +386,17 @@ bi_emit_discard_if(bi_context *ctx, nir_intrinsic_instr *instr)
                 },
         };
 
+        /* Try to fuse in the condition */
+        unsigned constants_left = 1, constant_shift = 0;
+
+        /* Scalar so no swizzle */
+        nir_alu_src wrap = {
+                .src = instr->src[0]
+        };
+
+        /* May or may not succeed but we're optimistic */
+        bi_fuse_cond(&discard, wrap, &constants_left, &constant_shift, 1, true);
+
         bi_emit(ctx, discard);
 }