From 3e2cb21e53cf9d5a3ef984ef5abbfd9683e516a8 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 27 Aug 2020 14:35:23 -0400 Subject: [PATCH] pan/mdg: Implement i/umul_high As imul with a .hi modifier, which implies a 64-bit computation. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_compile.c | 13 ++++++++++++- src/panfrost/midgard/midgard_schedule.c | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 7ab8cd46c1c..1b9ea1bd751 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -881,6 +881,8 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) ALU_CASE(iadd, iadd); ALU_CASE(isub, isub); ALU_CASE(imul, imul); + ALU_CASE(imul_high, imul); + ALU_CASE(umul_high, imul); /* Zero shoved as second-arg */ ALU_CASE(iabs, iabsdiff); @@ -1059,7 +1061,9 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) unsigned outmod = 0; bool is_int = midgard_is_integer_op(op); - if (midgard_is_integer_out_op(op)) { + if (instr->op == nir_op_umul_high || instr->op == nir_op_imul_high) { + outmod = midgard_outmod_int_high; + } else if (midgard_is_integer_out_op(op)) { outmod = midgard_outmod_int_wrap; } else if (instr->op == nir_op_fsat) { outmod = midgard_outmod_sat; @@ -2392,6 +2396,13 @@ max_bitsize_for_alu(midgard_instruction *ins) break; } + /* High implies computing at a higher bitsize, e.g umul_high of 32-bit + * requires computing at 64-bit */ + if (midgard_is_integer_out_op(ins->op) && ins->outmod == midgard_outmod_int_high) { + max_bitsize *= 2; + assert(max_bitsize <= 64); + } + return max_bitsize; } diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 3391e5360b2..63b1d781298 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -212,6 +212,9 @@ mir_is_scalar(midgard_instruction *ains) if (ains->src[1] != ~0) could_scalar &= (sz1 == 16) || (sz1 == 32); + if (midgard_is_integer_out_op(ains->op) && ains->outmod != midgard_outmod_int_wrap) + return false; + return could_scalar; } -- 2.30.2