From 96b38119ea3fe6ef11b5e024389640c6f7973cb2 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 21 Nov 2024 09:37:55 -0400 Subject: [PATCH] nir/pack_bits: handle 8-bit vec8 -> 64-bit This is a very silly case, but there's no reason not to handle it efficiently, and this implementation is faster than the fallback. Noticed when playing with scratch optimizations. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_builder.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index dc79d5e780d..ceb81ff45bd 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -1229,6 +1229,11 @@ nir_pack_bits(nir_builder *b, nir_def *src, unsigned dest_bit_size) return nir_pack_64_2x32(b, src); case 16: return nir_pack_64_4x16(b, src); + case 8: { + nir_def *lo = nir_pack_32_4x8(b, nir_channels(b, src, 0x0f)); + nir_def *hi = nir_pack_32_4x8(b, nir_channels(b, src, 0xf0)); + return nir_pack_64_2x32(b, nir_vec2(b, lo, hi)); + } default: break; }