From 659aa3dd6519f64379e91ca97fe184434fd7fdee Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 26 May 2019 03:16:37 +0000 Subject: [PATCH] panfrost/midgard: Implement fneg/fabs/fsat Fix a regression I inadvertently caused by acking typeless movs before implementing/pushing this *whistles* Nothing to see here, move along folks. Signed-off-by: Alyssa Rosenzweig --- .../drivers/panfrost/midgard/midgard_compile.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c index d8d3751..048389d 100644 --- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c +++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c @@ -864,6 +864,11 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) ALU_CASE(b32any_inequal3, ibany_neq); ALU_CASE(b32any_inequal4, ibany_neq); + /* Source mods will be shoved in later */ + ALU_CASE(fabs, fmov); + ALU_CASE(fneg, fmov); + ALU_CASE(fsat, fmov); + /* For greater-or-equal, we lower to less-or-equal and flip the * arguments */ @@ -928,6 +933,9 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) midgard_is_integer_out_op(op) ? midgard_outmod_int : instr->dest.saturate ? midgard_outmod_sat : midgard_outmod_none; + if (instr->op == nir_op_fsat) + outmod = midgard_outmod_sat; + /* fmax(a, 0.0) can turn into a .pos modifier as an optimization */ if (instr->op == nir_op_fmax) { @@ -977,6 +985,18 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) assert(0); } + /* These were lowered to a move, so apply the corresponding mod */ + + if (instr->op == nir_op_fneg || instr->op == nir_op_fabs) { + nir_alu_src *s = nirmods[quirk_flipped_r24]; + + if (instr->op == nir_op_fneg) + s->negate = !s->negate; + + if (instr->op == nir_op_fabs) + s->abs = !s->abs; + } + bool is_int = midgard_is_integer_op(op); midgard_vector_alu alu = { -- 2.7.4