Module: Mesa Branch: staging/22.2 Commit: 84ef8f31f6366dfed20d28bd4297f8849f00ee1a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=84ef8f31f6366dfed20d28bd4297f8849f00ee1a
Author: Pierre-Eric Pelloux-Prayer <[email protected]> Date: Fri Aug 19 15:04:19 2022 +0200 radeonsi: use nir_opt_large_constants earlier Calling it before nir_convert_to_lcssa helps in some cases, because the NIR is simpler and nir_opt_large_constants can detect that a variable is constant. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7059 CC: mesa-stable Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18147> (cherry picked from commit df2eaba4119e827a59596709373ad2491c4fbab4) --- .pick_status.json | 2 +- src/gallium/drivers/radeonsi/si_shader_nir.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index e7c9ff4744c..92d9e9643b2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -7816,7 +7816,7 @@ "description": "radeonsi: use nir_opt_large_constants earlier", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 46c7e135955..beeaa9adb21 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -351,6 +351,21 @@ char *si_finalize_nir(struct pipe_screen *screen, void *nirptr) if (sscreen->options.inline_uniforms) nir_find_inlinable_uniforms(nir); + /* Lower large variables that are always constant with load_constant intrinsics, which + * get turned into PC-relative loads from a data section next to the shader. + * + * Run this once before lcssa because the added phis may prevent this + * pass from operating correctly. + * + * nir_opt_large_constants may use op_amul (see nir_build_deref_offset), + * or may create unneeded code, so run si_nir_opts if needed. + */ + NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL); + bool progress = false; + NIR_PASS(progress, nir, nir_opt_large_constants, glsl_get_natural_size_align_bytes, 16); + if (progress) + si_nir_opts(sscreen, nir, false); + NIR_PASS_V(nir, nir_convert_to_lcssa, true, true); /* required by divergence analysis */ NIR_PASS_V(nir, nir_divergence_analysis); /* to find divergent loops */
