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 <alyssa@rosenzweig.io>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32322>
This commit is contained in:
Alyssa Rosenzweig 2024-11-21 09:37:55 -04:00
parent 4c84321683
commit 96b38119ea

View file

@ -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;
}