From: Alyssa Rosenzweig Date: Mon, 4 May 2020 20:12:41 +0000 (-0400) Subject: pan/mdg: Ingest fsat_signed/fclamp_pos X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=24e2e24dc0124e5c5f9426a5f571a487b2ac6bfe;p=mesa.git pan/mdg: Ingest fsat_signed/fclamp_pos Signed-off-by: Alyssa Rosenzweig Part-of: --- 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)), ]