From 201782d0fa66fccda8bd925b83405f412d823f9d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 26 May 2022 10:58:10 -0700 Subject: [PATCH] intel/fs: Always do opt_algebraic after opt_copy_propagation makes progress opt_copy_propagation can create invalid instructions like shl(8) vgrf96:UD, 2d, 8u These instructions will be cleaned up by opt_algebraic. The irony is opt_algebraic converts these to simple mov instructions that opt_copy_propagation should clean up. I don't think we want a loop like do { progress = false; if (OPT(opt_copy_propagation)) { OPT(opt_algebraic); OPT(dead_code_eliminate); } } while (progress); But maybe we do? Maybe this would be sufficient: while (OPT(opt_copy_propagation)) OPT(opt_algebraic); OPT(dead_code_eliminate); No shader-db or fossil-db changes (yet) on any Intel platform. This is expected. v2: Do opt_algebraic immediately after every call to opt_copy_propagation instead of being clever. Suggested by Lionel. Tested-by: Lionel Landwerlin Reviewed-by: Lionel Landwerlin Reviewed-by: Kenneth Graunke (cherry picked from commit 56e6186dcf0b664e1595eaee7878a40c65857010) Part-of: --- src/intel/compiler/brw_fs.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 8e28a072bfd..42e23e7e08a 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -6150,12 +6150,15 @@ fs_visitor::optimize() OPT(fixup_nomask_control_flow); if (progress) { - OPT(opt_copy_propagation); + if (OPT(opt_copy_propagation)) + OPT(opt_algebraic); + /* Only run after logical send lowering because it's easier to implement * in terms of physical sends. */ - if (OPT(opt_zero_samples)) - OPT(opt_copy_propagation); + if (OPT(opt_zero_samples) && OPT(opt_copy_propagation)) + OPT(opt_algebraic); + /* Run after logical send lowering to give it a chance to CSE the * LOAD_PAYLOAD instructions created to construct the payloads of * e.g. texturing messages in cases where it wasn't possible to CSE the @@ -6197,7 +6200,8 @@ fs_visitor::optimize() if (devinfo->ver <= 5 && OPT(lower_minmax)) { OPT(opt_cmod_propagation); OPT(opt_cse); - OPT(opt_copy_propagation); + if (OPT(opt_copy_propagation)) + OPT(opt_algebraic); OPT(dead_code_eliminate); } @@ -6205,7 +6209,8 @@ fs_visitor::optimize() OPT(lower_derivatives); OPT(lower_regioning); if (progress) { - OPT(opt_copy_propagation); + if (OPT(opt_copy_propagation)) + OPT(opt_algebraic); OPT(dead_code_eliminate); OPT(lower_simd_width); }