[Mesa-dev] [PATCH 19/19] panfrost/midgard: Optimize MIR in progress loop

Alyssa Rosenzweig alyssa at rosenzweig.io
Mon Apr 22 05:04:26 UTC 2019


Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
---
 .../drivers/panfrost/midgard/midgard_compile.c   | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index d297e505c1c..2c259ea525a 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -3685,12 +3685,18 @@ midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_bl
 
         util_dynarray_init(compiled, NULL);
 
-        /* Peephole optimizations */
+        /* MIR-level optimizations */
 
-        mir_foreach_block(ctx, block) {
-                midgard_opt_copy_prop(ctx, block);
-                midgard_opt_dead_code_eliminate(ctx, block);
-        }
+        bool progress = false;
+
+        do {
+                progress = false;
+
+                mir_foreach_block(ctx, block) {
+                        progress |= midgard_opt_copy_prop(ctx, block);
+                        progress |= midgard_opt_dead_code_eliminate(ctx, block);
+                }
+        } while (progress);
 
         /* Schedule! */
         schedule_program(ctx);
-- 
2.20.1



More information about the mesa-dev mailing list