From 24d2bdb1e050134a25924487792ee0018f8478ae Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 17 Feb 2022 19:34:04 -0500 Subject: [PATCH] pan/bi: Avoid *FADD.v2f16 hazard in scheduler Obscure encoding restriction. Fixes crash (assertion fail when instruction packing) in asphalt9/2659.shader_test on Bifrost. Signed-off-by: Alyssa Rosenzweig Cc: mesa-stable Part-of: --- src/panfrost/bifrost/bi_schedule.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index 88162ecc86e..4c6770e7719 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -490,6 +490,18 @@ bi_can_iaddc(bi_instr *ins) ins->src[1].swizzle == BI_SWIZZLE_H01); } +/* + * The encoding of *FADD.v2f16 only specifies a single abs flag. All abs + * encodings are permitted by swapping operands; however, this scheme fails if + * both operands are equal. Test for this case. + */ +static bool +bi_impacted_abs(bi_instr *I) +{ + return I->src[0].abs && I->src[1].abs && + bi_is_word_equiv(I->src[0], I->src[1]); +} + bool bi_can_fma(bi_instr *ins) { @@ -497,6 +509,10 @@ bi_can_fma(bi_instr *ins) if (bi_can_iaddc(ins)) return true; + /* *FADD.v2f16 has restricted abs modifiers, use +FADD.v2f16 instead */ + if (ins->op == BI_OPCODE_FADD_V2F16 && bi_impacted_abs(ins)) + return false; + /* TODO: some additional fp16 constraints */ return bi_opcode_props[ins->op].fma; }