diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 16eeae7e42f..917b1475b3a 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1412,6 +1412,7 @@ struct nir_shader *si_get_nir_shader(struct si_shader_selector *sel, nir->info.inlinable_uniform_dw_offsets); si_nir_opts(sel->screen, nir, true); + si_nir_late_opts(nir); /* This must be done again. */ NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_in | diff --git a/src/gallium/drivers/radeonsi/si_shader.h b/src/gallium/drivers/radeonsi/si_shader.h index 7c0874f26d7..a8809af340e 100644 --- a/src/gallium/drivers/radeonsi/si_shader.h +++ b/src/gallium/drivers/radeonsi/si_shader.h @@ -877,6 +877,7 @@ struct si_shader *si_generate_gs_copy_shader(struct si_screen *sscreen, /* si_shader_nir.c */ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *info); void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first); +void si_nir_late_opts(nir_shader *nir); void si_finalize_nir(struct pipe_screen *screen, void *nirptr, bool optimize); /* si_state_shaders.c */ diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 6f2d5348262..66a1637752e 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -550,6 +550,19 @@ void si_nir_opts(struct si_screen *sscreen, struct nir_shader *nir, bool first) NIR_PASS_V(nir, nir_lower_var_copies); } +void si_nir_late_opts(nir_shader *nir) +{ + bool more_late_algebraic = true; + while (more_late_algebraic) { + more_late_algebraic = false; + NIR_PASS(more_late_algebraic, nir, nir_opt_algebraic_late); + NIR_PASS_V(nir, nir_opt_constant_folding); + NIR_PASS_V(nir, nir_copy_prop); + NIR_PASS_V(nir, nir_opt_dce); + NIR_PASS_V(nir, nir_opt_cse); + } +} + static int type_size_vec4(const struct glsl_type *type, bool bindless) { return glsl_count_attribute_slots(type, false); @@ -765,15 +778,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir) si_nir_opts(sscreen, nir, false); /* Run late optimizations to fuse ffma. */ - bool more_late_algebraic = true; - while (more_late_algebraic) { - more_late_algebraic = false; - NIR_PASS(more_late_algebraic, nir, nir_opt_algebraic_late); - NIR_PASS_V(nir, nir_opt_constant_folding); - NIR_PASS_V(nir, nir_copy_prop); - NIR_PASS_V(nir, nir_opt_dce); - NIR_PASS_V(nir, nir_opt_cse); - } + si_nir_late_opts(nir); NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);