From 7e1d1e2caaa99828c75b6bea5cb8019e0af2dfe6 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 23 Jun 2025 16:35:54 +0200 Subject: [PATCH] nak: Provide our own callback to nir_lower_phis_to_scalar The default callback of nir_lower_phis_to_scalar internally uses is_phi_src_scalarizable to determine wether to scalarize a phi vector, however not doing that helps NAK. shader-db stats on ga102: Totals: CodeSize: 938039520 -> 938024464 (-0.00%); split: -0.00%, +0.00% SLM Size: 878396 -> 876376 (-0.23%) Static cycle count: 225000863 -> 224999103 (-0.00%); split: -0.00%, +0.00% Totals from 140 (0.16% of 87622) affected shaders: CodeSize: 1353760 -> 1338704 (-1.11%); split: -1.42%, +0.31% SLM Size: 8160 -> 6140 (-24.75%) Static cycle count: 316178 -> 314418 (-0.56%); split: -0.71%, +0.16% Reviewed-by: Mel Henning Part-of: --- src/nouveau/compiler/nak_nir.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nouveau/compiler/nak_nir.c b/src/nouveau/compiler/nak_nir.c index 61efbc7f09a..6a89401e808 100644 --- a/src/nouveau/compiler/nak_nir.c +++ b/src/nouveau/compiler/nak_nir.c @@ -88,6 +88,12 @@ vectorize_filter_cb(const nir_instr *instr, const void *_data) } } +static uint8_t +phi_vectorize_cb(const nir_instr *instr, const void *data) +{ + return 1; +} + static void optimize_nir(nir_shader *nir, const struct nak_compiler *nak, bool allow_copies) { @@ -130,7 +136,7 @@ optimize_nir(nir_shader *nir, const struct nak_compiler *nak, bool allow_copies) OPT(nir, nir_lower_alu_width, vectorize_filter_cb, NULL); OPT(nir, nir_opt_vectorize, vectorize_filter_cb, NULL); - OPT(nir, nir_lower_phis_to_scalar, NULL, NULL); + OPT(nir, nir_lower_phis_to_scalar, phi_vectorize_cb, NULL); OPT(nir, nir_lower_frexp); OPT(nir, nir_copy_prop); OPT(nir, nir_opt_dce);