agx: Add min/max support
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 18 Apr 2021 19:16:04 +0000 (15:16 -0400)
committerAlyssa Rosenzweig <none>
Sun, 2 May 2021 21:41:19 +0000 (17:41 -0400)
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10582>

src/asahi/compiler/agx_compile.c

index 6061e00..727b6ff 100644 (file)
@@ -365,6 +365,13 @@ agx_emit_alu(agx_builder *b, nir_alu_instr *instr)
    case nir_op_fabs: return agx_fmov_to(b, dst, agx_abs(s0));
    case nir_op_fneg: return agx_fmov_to(b, dst, agx_neg(s0));
 
+   case nir_op_fmin: return agx_fcmpsel_to(b, dst, s0, s1, s0, s1, AGX_FCOND_LTN);
+   case nir_op_fmax: return agx_fcmpsel_to(b, dst, s0, s1, s0, s1, AGX_FCOND_GTN);
+   case nir_op_imin: return agx_icmpsel_to(b, dst, s0, s1, s0, s1, AGX_ICOND_SLT);
+   case nir_op_imax: return agx_icmpsel_to(b, dst, s0, s1, s0, s1, AGX_ICOND_SGT);
+   case nir_op_umin: return agx_icmpsel_to(b, dst, s0, s1, s0, s1, AGX_ICOND_ULT);
+   case nir_op_umax: return agx_icmpsel_to(b, dst, s0, s1, s0, s1, AGX_ICOND_UGT);
+
    case nir_op_iadd: return agx_iadd_to(b, dst, s0, s1, 0);
    case nir_op_isub: return agx_iadd_to(b, dst, s0, agx_neg(s1), 0);
    case nir_op_ineg: return agx_iadd_to(b, dst, agx_zero(), agx_neg(s0), 0);