From 2af84c2d49285ef4e0c353712ed91a9bd8c6a044 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 8 Mar 2024 23:20:29 -0800 Subject: [PATCH] intel/brw: Use the defs-based copy propagation along with the old one The new def-based pass works better in many cases, and should be less resource intensive. However, the limited visibility of the defs-based pass due to many values not being SSA yet makes it unable to fully replace the old pass. Try the new one, and if it can't make progress, then try the old one. That way, things will mostly be handled by the new pass, but everything that was being cleaned up still will be. Reviewed-by: Caio Oliveira Part-of: --- src/intel/compiler/brw_fs_opt.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw_fs_opt.cpp b/src/intel/compiler/brw_fs_opt.cpp index 2a0b4aefeb6..b2172c04ecf 100644 --- a/src/intel/compiler/brw_fs_opt.cpp +++ b/src/intel/compiler/brw_fs_opt.cpp @@ -63,7 +63,8 @@ brw_fs_optimize(fs_visitor &s) OPT(brw_fs_opt_algebraic); OPT(brw_fs_opt_cse_defs); - OPT(brw_fs_opt_copy_propagation); + if (!OPT(brw_fs_opt_copy_propagation_defs)) + OPT(brw_fs_opt_copy_propagation); OPT(brw_fs_opt_predicated_break); OPT(brw_fs_opt_cmod_propagation); OPT(brw_fs_opt_dead_code_eliminate); @@ -89,20 +90,20 @@ brw_fs_optimize(fs_visitor &s) /* After logical SEND lowering. */ - if (OPT(brw_fs_opt_copy_propagation)) + if (OPT(brw_fs_opt_copy_propagation_defs) || OPT(brw_fs_opt_copy_propagation)) OPT(brw_fs_opt_algebraic); /* Identify trailing zeros LOAD_PAYLOAD of sampler messages. * Do this before splitting SENDs. */ - if (OPT(brw_fs_opt_zero_samples) && OPT(brw_fs_opt_copy_propagation)) + if (OPT(brw_fs_opt_zero_samples) && (OPT(brw_fs_opt_copy_propagation_defs) || OPT(brw_fs_opt_copy_propagation))) OPT(brw_fs_opt_algebraic); OPT(brw_fs_opt_split_sends); OPT(brw_fs_workaround_nomask_control_flow); if (progress) { - if (OPT(brw_fs_opt_copy_propagation)) + if (OPT(brw_fs_opt_copy_propagation_defs) || OPT(brw_fs_opt_copy_propagation)) OPT(brw_fs_opt_algebraic); /* Run after logical send lowering to give it a chance to CSE the @@ -142,7 +143,12 @@ brw_fs_optimize(fs_visitor &s) OPT(brw_fs_lower_derivatives); OPT(brw_fs_lower_regioning); if (progress) { - if (OPT(brw_fs_opt_copy_propagation)) { + /* Try both copy propagation passes. The defs one will likely not be + * able to handle everything at this point. + */ + const bool cp1 = OPT(brw_fs_opt_copy_propagation_defs); + const bool cp2 = OPT(brw_fs_opt_copy_propagation); + if (cp1 || cp2) { OPT(brw_fs_opt_algebraic); OPT(brw_fs_opt_combine_constants); }