nir: optimize unpacking 8bit values from a 64bit source

Useful for load vectorization.

Foz-DB Navi21:
Totals from 299 (0.38% of 79395) affected shaders:
Instrs: 287818 -> 284333 (-1.21%); split: -1.21%, +0.00%
CodeSize: 1557124 -> 1540544 (-1.06%); split: -1.07%, +0.00%
Latency: 4009407 -> 4012389 (+0.07%); split: -0.05%, +0.12%
InvThroughput: 1260613 -> 1262530 (+0.15%); split: -0.01%, +0.17%
VClause: 5472 -> 5369 (-1.88%); split: -1.92%, +0.04%
SClause: 5419 -> 5305 (-2.10%); split: -2.58%, +0.48%
Copies: 36709 -> 36060 (-1.77%); split: -1.81%, +0.04%
PreSGPRs: 11861 -> 11655 (-1.74%)
SALU: 66920 -> 64310 (-3.90%)

Reviewed-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32778>
This commit is contained in:
Georg Lehmann
2024-12-24 16:29:31 +01:00
committed by Marge Bot
parent 47cdec24ee
commit 5b4b195f1b
+9
View File
@@ -1278,6 +1278,15 @@ nir_unpack_bits(nir_builder *b, nir_def *src, unsigned dest_bit_size)
return nir_unpack_64_2x32(b, src);
case 16:
return nir_unpack_64_4x16(b, src);
case 8: {
nir_def *split = nir_unpack_64_2x32(b, src);
nir_def *lo = nir_unpack_32_4x8(b, nir_channel(b, split, 0));
nir_def *hi = nir_unpack_32_4x8(b, nir_channel(b, split, 1));
return nir_vec8(b, nir_channel(b, lo, 0), nir_channel(b, lo, 1),
nir_channel(b, lo, 2), nir_channel(b, lo, 3),
nir_channel(b, hi, 0), nir_channel(b, hi, 1),
nir_channel(b, hi, 2), nir_channel(b, hi, 3));
}
default:
break;
}