From f66883a87500c0b37efec7496f428531a1c7f8f4 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Tue, 23 Apr 2024 19:07:48 +0200 Subject: [PATCH] nir: lower pack_uvec4_to_uint to pack_32_4x8 if supported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Timur Kristóf Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir_lower_alu_width.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/nir/nir_lower_alu_width.c b/src/compiler/nir/nir_lower_alu_width.c index 3bc6b187df5..7d1f8a98d59 100644 --- a/src/compiler/nir/nir_lower_alu_width.c +++ b/src/compiler/nir/nir_lower_alu_width.c @@ -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))),