Module: Mesa
Branch: main
Commit: 61c7e1bf48f620cc81b6273cbaf595b7e27d80b7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=61c7e1bf48f620cc81b6273cbaf595b7e27d80b7

Author: Alyssa Rosenzweig <[email protected]>
Date:   Thu Dec 29 18:04:40 2022 -0500

agx: Peephole select after opt_preamble

Reduces control flow in Dolphin uber shaders, which saves us a few cycles.

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20597>

---

 src/asahi/compiler/agx_compile.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index 9c7a41624b4..bd15c59f03b 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -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);
 

Reply via email to