[Mesa-dev] [PATCH 04/25] i965/fs: Run SIMD and logical send lowering after the optimization loop.

Francisco Jerez currojerez at riseup.net
Sat May 28 02:05:45 UTC 2016


There are two reasons why this is useful:

 - It avoids the introduction of an amount of partial writes emitted
   by the SIMD lowering pass to zip and unzip register regions early
   during optimization, which can make subsequent optimization less
   effective.

 - It substantially reduces the burden on the compiler when a large
   fraction of the instructions in the program need to be split (e.g.
   during SIMD32 builds).  Individual halves of split instructions
   will be optimized identically (if they can still be optimized at
   all), so doing it up front can duplicate the amount of instructions
   the optimizer has to deal with which causes the compilation time to
   explode in some cases due to the worse-than-linear runtime
   behaviour of the back-end.

It seems helpful to re-run a few optimization passes in cases where
any of the lowering passes was able to make progress.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index b7954bb..20feb6f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -5707,9 +5707,6 @@ fs_visitor::optimize()
 
    OPT(opt_drop_redundant_mov_to_flags);
 
-   OPT(lower_simd_width);
-   OPT(lower_logical_sends);
-
    do {
       progress = false;
       pass_num = 0;
@@ -5728,7 +5725,6 @@ fs_visitor::optimize()
       OPT(opt_register_renaming);
       OPT(opt_redundant_discard_jumps);
       OPT(opt_saturate_propagation);
-      OPT(opt_zero_samples);
       OPT(register_coalesce);
       OPT(compute_to_mrf);
       OPT(eliminate_find_live_channel);
@@ -5736,8 +5732,33 @@ fs_visitor::optimize()
       OPT(compact_virtual_grfs);
    } while (progress);
 
+   progress = false;
    pass_num = 0;
 
+   OPT(lower_simd_width);
+   OPT(lower_logical_sends);
+
+   if (progress) {
+      OPT(opt_copy_propagate);
+      /* 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_propagate);
+      /* 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
+       * whole logical instruction.
+       */
+      OPT(opt_cse);
+      OPT(register_coalesce);
+      OPT(compute_to_mrf);
+      OPT(dead_code_eliminate);
+      OPT(remove_duplicate_mrf_writes);
+      OPT(opt_peephole_sel);
+      OPT(opt_redundant_discard_jumps);
+   }
+
    OPT(opt_sampler_eot);
 
    if (OPT(lower_load_payload)) {
-- 
2.7.3



More information about the mesa-dev mailing list