agx: DCE even with noopt
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 4 Mar 2023 22:13:30 +0000 (17:13 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 7 Apr 2023 03:23:03 +0000 (03:23 +0000)
To simplify live range splitting, RA will soon assume that DCE has run (removing
extraneous vectors). So run DCE even when otherwise disabling backend
optimizations. AGX_MESA_DEBUG=noopt is still useful for disabling instruction
combining, which is the more-likely-to-be-buggy pass anyway.

This also fixes IR not being printed with noopt.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22353>

src/asahi/compiler/agx_compile.c

index 2de1989..cd4a543 100644 (file)
@@ -2186,23 +2186,20 @@ agx_compile_function_nir(nir_shader *nir, nir_function_impl *impl,
 
       /* After DCE, use counts are right so we can run the optimizer. */
       agx_optimizer(ctx);
+   }
 
-      /* For correctness, lower uniform sources after copyprop (for correctness,
-       * as copyprop creates uniform sources). To keep register pressure in
-       * check, lower after CSE, since moves are cheaper than registers.
-       */
-      agx_lower_uniform_sources(ctx);
+   /* For correctness, lower uniform sources after copyprop (for correctness,
+    * as copyprop creates uniform sources). To keep register pressure in
+    * check, lower after CSE, since moves are cheaper than registers.
+    */
+   agx_lower_uniform_sources(ctx);
 
-      /* Dead code eliminate after instruction combining to get the benefit */
-      agx_dce(ctx, true);
-      agx_validate(ctx, "Optimization");
+   /* RA correctness depends on DCE */
+   agx_dce(ctx, true);
+   agx_validate(ctx, "Pre-RA passes");
 
-      if (agx_should_dump(nir, AGX_DBG_SHADERS))
-         agx_print_shader(ctx, stdout);
-   } else {
-      /* We need to lower regardless */
-      agx_lower_uniform_sources(ctx);
-   }
+   if (agx_should_dump(nir, AGX_DBG_SHADERS))
+      agx_print_shader(ctx, stdout);
 
    agx_ra(ctx);
    agx_lower_64bit_postra(ctx);