From 9d7e25a9a96f944905ea669fe4ddafa0d6a5f7bd Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 6 May 2021 13:10:00 -0400 Subject: [PATCH] pan/bi: Allow IADD.u32 on FMA as *IADDC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's a common special case, slight boost in scheduler freedom. total nops in shared programs: 101130 -> 101048 (-0.08%) nops in affected programs: 1677 -> 1595 (-4.89%) helped: 13 HURT: 0 helped stats (abs) min: 6 max: 8 x̄: 6.31 x̃: 6 helped stats (rel) min: 3.24% max: 25.00% x̄: 7.42% x̃: 4.48% 95% mean confidence interval for nops value: -6.76 -5.85 95% mean confidence interval for nops %-change: -12.02% -2.81% Nops are helped. total clauses in shared programs: 27076 -> 27075 (<.01%) clauses in affected programs: 8 -> 7 (-12.50%) helped: 1 HURT: 0 total quadwords in shared programs: 113142 -> 113113 (-0.03%) quadwords in affected programs: 1935 -> 1906 (-1.50%) helped: 13 HURT: 0 helped stats (abs) min: 2 max: 4 x̄: 2.23 x̃: 2 helped stats (rel) min: 0.95% max: 7.50% x̄: 2.16% x̃: 1.26% 95% mean confidence interval for quadwords value: -2.59 -1.87 95% mean confidence interval for quadwords %-change: -3.45% -0.88% Quadwords are helped. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_schedule.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index f4a8873bcce..9fa069e900d 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -329,6 +329,15 @@ bi_back_to_back(bi_block *block) /* Scheduler predicates */ +/* IADDC.i32 can implement IADD.u32 if no saturation or swizzling is in use */ +static bool +bi_can_iaddc(bi_instr *ins) +{ + return (ins->op == BI_OPCODE_IADD_U32 && !ins->saturate && + ins->src[0].swizzle == BI_SWIZZLE_H01 && + ins->src[1].swizzle == BI_SWIZZLE_H01); +} + ASSERTED static bool bi_can_fma(bi_instr *ins) { @@ -338,6 +347,10 @@ bi_can_fma(bi_instr *ins) !bi_is_word_equiv(ins->src[0], ins->src[1])) return false; + /* +IADD.i32 -> *IADDC.i32 */ + if (bi_can_iaddc(ins)) + return true; + /* TODO: some additional fp16 constraints */ return bi_opcode_props[ins->op].fma; } @@ -903,6 +916,13 @@ bi_take_instr(bi_context *ctx, struct bi_worklist st, bi_update_worklist(st, idx); bi_pop_instr(clause, tuple, instr, live_after_temp, fma); + /* Fixups */ + if (instr->op == BI_OPCODE_IADD_U32 && fma) { + assert(bi_can_iaddc(instr)); + instr->op = BI_OPCODE_IADDC_I32; + instr->src[2] = bi_zero(); + } + return instr; }