nir: lower pack_uvec4_to_uint to pack_32_4x8 if supported

Foz-DB Navi31:
Totals from 42 (0.05% of 79395) affected shaders:
Instrs: 3326544 -> 3324640 (-0.06%)
CodeSize: 16908376 -> 16896212 (-0.07%); split: -0.07%, +0.00%
VGPRs: 4284 -> 4296 (+0.28%)
Latency: 17862544 -> 17855438 (-0.04%); split: -0.05%, +0.01%
InvThroughput: 3535291 -> 3533993 (-0.04%); split: -0.04%, +0.00%
VClause: 95270 -> 95275 (+0.01%); split: -0.01%, +0.01%
SClause: 65402 -> 65397 (-0.01%)
Copies: 229723 -> 234124 (+1.92%)
Branches: 109481 -> 109518 (+0.03%); split: -0.00%, +0.04%
PreVGPRs: 3879 -> 3909 (+0.77%)
VALU: 1789208 -> 1787370 (-0.10%); split: -0.10%, +0.00%
SALU: 409136 -> 409129 (-0.00%); split: -0.00%, +0.00%

Tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28882>
This commit is contained in:
Georg Lehmann 2024-04-23 19:07:48 +02:00 committed by Marge Bot
parent a3f77e09a1
commit f66883a875

View file

@ -265,6 +265,9 @@ lower_alu_instr_width(nir_builder *b, nir_instr *instr, void *_data)
assert(b->shader->options->lower_pack_snorm_4x8 ||
b->shader->options->lower_pack_unorm_4x8);
if (b->shader->options->has_pack_32_4x8)
return nir_pack_32_4x8(b, nir_u2u8(b, nir_ssa_for_alu_src(b, alu, 0)));
nir_def *byte = nir_extract_u8(b, nir_ssa_for_alu_src(b, alu, 0),
nir_imm_int(b, 0));
return nir_ior(b, nir_ior(b, nir_ishl(b, nir_channel(b, byte, 3), nir_imm_int(b, 24)), nir_ishl(b, nir_channel(b, byte, 2), nir_imm_int(b, 16))),