pan/mdg: Implement i/umul_high
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 27 Aug 2020 18:35:23 +0000 (14:35 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 31 Aug 2020 11:46:31 +0000 (07:46 -0400)
As imul with a .hi modifier, which implies a 64-bit computation.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6516>

src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_schedule.c

index 7ab8cd46c1c7b821e61e37ed0a791a6d242d5100..1b9ea1bd7516c7ab8adf020251cc18997a9e72fe 100644 (file)
@@ -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;
 }
 
index 3391e5360b2f340555b55ca92f334fd6c06768e0..63b1d781298b138fe170bde96930799674fabd4c 100644 (file)
@@ -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;
 }