diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index ab29036c10d..eff8d159e18 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -3183,8 +3183,7 @@ nir_lower_io_passes(nir_shader *nir) /* Lower and remove dead derefs and variables to clean up the IR. */ NIR_PASS_V(nir, nir_lower_vars_to_ssa); NIR_PASS_V(nir, nir_opt_dce); - NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp | - nir_var_shader_in | nir_var_shader_out, NULL); + NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL); if (nir->xfb_info) NIR_PASS_V(nir, nir_io_add_intrinsic_xfb_info); diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index e5424c459ee..62f3a2d513c 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -413,6 +413,7 @@ char *si_finalize_nir(struct pipe_screen *screen, void *nirptr) struct nir_shader *nir = (struct nir_shader *)nirptr; nir_lower_io_passes(nir); + NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in | nir_var_shader_out, NULL); NIR_PASS_V(nir, ac_nir_lower_subdword_loads, (ac_nir_lower_subdword_options) { diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 02d588bc35a..ed2ef5c6925 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -1076,8 +1076,11 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, /* Lower load_deref/store_deref of inputs and outputs. * This depends on st_nir_assign_varying_locations. */ - if (nir->options->lower_io_variables) + if (nir->options->lower_io_variables) { nir_lower_io_passes(nir); + NIR_PASS_V(nir, nir_remove_dead_variables, + nir_var_shader_in | nir_var_shader_out, NULL); + } /* Set num_uniforms in number of attribute slots (vec4s) */ nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);