agx: Peephole select after opt_preamble
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 29 Dec 2022 23:04:40 +0000 (18:04 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 13 Jan 2023 00:43:04 +0000 (00:43 +0000)
Reduces control flow in Dolphin uber shaders, which saves us a few cycles.

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

src/asahi/compiler/agx_compile.c

index 9c7a416..bd15c59 100644 (file)
@@ -1702,6 +1702,14 @@ agx_optimize_nir(nir_shader *nir, unsigned *preamble_size)
    NIR_PASS_V(nir, nir_lower_int64);
 
    NIR_PASS_V(nir, agx_nir_opt_preamble, preamble_size);
+
+   /* Forming preambles may dramatically reduce the instruction count
+    * in certain blocks, causing some if-else statements to become
+    * trivial. We want to peephole select those, given that control flow
+    * prediction instructions are costly.
+    */
+   NIR_PASS_V(nir, nir_opt_peephole_select, 64, false, true);
+
    NIR_PASS_V(nir, nir_opt_algebraic_late);
    NIR_PASS_V(nir, nir_opt_constant_folding);