From 24e2e24dc0124e5c5f9426a5f571a487b2ac6bfe Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 4 May 2020 16:12:41 -0400 Subject: [PATCH] pan/mdg: Ingest fsat_signed/fclamp_pos Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_compile.c | 2 ++ src/panfrost/midgard/midgard_nir_algebraic.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 907634b1e13..0f57ba67626 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -770,6 +770,8 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) ALU_CASE(fabs, fmov); ALU_CASE(fneg, fmov); ALU_CASE(fsat, fmov); + ALU_CASE(fsat_signed, fmov); + ALU_CASE(fclamp_pos, fmov); /* For size conversion, we use a move. Ideally though we would squash * these ops together; maybe that has to happen after in NIR as part of diff --git a/src/panfrost/midgard/midgard_nir_algebraic.py b/src/panfrost/midgard/midgard_nir_algebraic.py index ae399c36d5b..d7eceeba869 100644 --- a/src/panfrost/midgard/midgard_nir_algebraic.py +++ b/src/panfrost/midgard/midgard_nir_algebraic.py @@ -45,6 +45,13 @@ algebraic_late = [ (('b32csel', a, 'b@32', 0), ('iand', a, b)), (('b32csel', a, 0, 'b@32'), ('iand', ('inot', a), b)), + + # Fuse sat_signed. This should probably be shared with Bifrost + (('~fmin', ('fmax', a, -1.0), 1.0), ('fsat_signed', a)), + (('~fmax', ('fmin', a, 1.0), -1.0), ('fsat_signed', a)), + + # Fuse clamp_positive. This should probably be shared with Utgard/bifrost + (('fmax', a, 0.0), ('fclamp_pos', a)), ] -- 2.30.2