From 857f29d67bfa72d95f6ecedd6107315908d82abb Mon Sep 17 00:00:00 2001 From: Romaric Jodin Date: Fri, 4 Jul 2025 14:59:23 +0200 Subject: [PATCH] pan/bi: use only 1 MKVEC.v2i8 to generate v4i8 when possible When making a vector of 4 elements, try to make it with only 1 instruction instead of 2 at the moment, if the last 2 elements respect the pattern supported by MKVEC.v2i8 Reviewed-by: Mary Guillemard Part-of: --- src/panfrost/compiler/bifrost_compile.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/panfrost/compiler/bifrost_compile.c b/src/panfrost/compiler/bifrost_compile.c index 5ab3c266e52..ab73ea1d8cb 100644 --- a/src/panfrost/compiler/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost_compile.c @@ -761,8 +761,17 @@ bi_make_vec8_helper(bi_builder *b, bi_index *src, unsigned *channel, if (b->shader->arch >= 9) { bi_index vec = bi_zero(); - if (count >= 3) - vec = bi_mkvec_v2i8(b, bytes[2], bytes[3], vec); + if (count >= 3) { + if ((count == 3 && bytes[2].swizzle == BI_SWIZZLE_B0) || + (count == 4 && bi_is_word_equiv(bytes[2], bytes[3]) && + bytes[2].swizzle == BI_SWIZZLE_B0 && + bytes[3].swizzle == BI_SWIZZLE_B1)) { + vec = bytes[2]; + vec.swizzle = BI_SWIZZLE_B0123; + } else { + vec = bi_mkvec_v2i8(b, bytes[2], bytes[3], vec); + } + } return bi_mkvec_v2i8(b, bytes[0], bytes[1], vec); } else {