lima: Lower undefs to zero and run DCE after from_ssa

Undefs can happen even in real GLSL shaders so it's best to handle them.
Lowering to zero is a perfectly valid implementation.  Also, run DCE
because some of the undefs may be dead after from_ssa and there's no
point in processing those in the back-end.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16817>
This commit is contained in:
Jason Ekstrand
2022-06-01 14:43:18 -05:00
committed by Marge Bot
parent 6f873dd267
commit c5c90e6ea4

View File

@@ -139,6 +139,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
NIR_PASS(progress, s, lima_nir_lower_ftrunc);
NIR_PASS(progress, s, nir_opt_constant_folding);
NIR_PASS(progress, s, nir_opt_undef);
NIR_PASS(progress, s, nir_lower_undef_to_zero);
NIR_PASS(progress, s, nir_opt_loop_unroll);
NIR_PASS(progress, s, nir_lower_undef_to_zero);
} while (progress);
@@ -153,6 +154,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s)
NIR_PASS_V(s, lima_nir_split_loads);
NIR_PASS_V(s, nir_lower_locals_to_regs);
NIR_PASS_V(s, nir_convert_from_ssa, true);
NIR_PASS_V(s, nir_opt_dce);
NIR_PASS_V(s, nir_remove_dead_variables, nir_var_function_temp, NULL);
nir_sweep(s);
}