Module: Mesa
Branch: main
Commit: 5e031867fe0eb2bd4b3fc0f013d54a6afe5f82fb
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e031867fe0eb2bd4b3fc0f013d54a6afe5f82fb

Author: Alyssa Rosenzweig <[email protected]>
Date:   Fri Feb 17 18:35:40 2023 -0500

agx: Handle ssa_undef as zero

Masked stores may result in undefs after optimization. Rather than call
lower_undef_to_zero late (but get no benefit), we may as well handle ourselves
to prepare for proper undef support down the line.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21431>

---

 src/asahi/compiler/agx_compile.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index b5e8c3f69e3..277fe5fad96 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -1533,6 +1533,16 @@ agx_emit_phis_deferred(agx_context *ctx)
    }
 }
 
+static void
+agx_emit_undef(agx_builder *b, nir_ssa_undef_instr *instr)
+{
+   /* For now, just lower undefs to zero. This doesn't matter too much, since
+    * the lowering happens in NIR and this just allows for late lowering passes
+    * to result in undefs.
+    */
+   agx_mov_imm_to(b, agx_nir_ssa_index(&instr->def), 0);
+}
+
 static void
 agx_emit_instr(agx_builder *b, struct nir_instr *instr)
 {
@@ -1561,6 +1571,10 @@ agx_emit_instr(agx_builder *b, struct nir_instr *instr)
       agx_emit_phi(b, nir_instr_as_phi(instr));
       break;
 
+   case nir_instr_type_ssa_undef:
+      agx_emit_undef(b, nir_instr_as_ssa_undef(instr));
+      break;
+
    default:
       unreachable("should've been lowered");
    }

Reply via email to