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 <lionel.g.landwerlin@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23884>
This commit is contained in:
Ian Romanick
2022-05-26 10:58:10 -07:00
committed by Marge Bot
parent d089272fc0
commit 56e6186dcf

View File

@@ -6116,12 +6116,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
@@ -6163,7 +6166,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);
}
@@ -6171,7 +6175,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);
}