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 <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35604>
This commit is contained in:
Karol Herbst 2025-06-23 16:35:54 +02:00 committed by Marge Bot
parent c16e786c75
commit 7e1d1e2caa

View file

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