agx: Run opt_idiv_const after lowering texture
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Fri, 18 Aug 2023 23:05:36 +0000 (19:05 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 5 Sep 2023 18:50:34 +0000 (18:50 +0000)
Shaves 10 instructions off the cube map array lowering.

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

src/asahi/compiler/agx_compile.c

index f8e9bc4..6b99843 100644 (file)
@@ -2724,6 +2724,11 @@ agx_preprocess_nir(nir_shader *nir, bool support_lod_bias, bool allow_mediump,
    NIR_PASS_V(nir, nir_opt_dce);
    NIR_PASS_V(nir, agx_nir_lower_texture, support_lod_bias);
 
+   /* Runs before we lower away idiv, to work at all. But runs after lowering
+    * textures, since the cube map array lowering generates division by 6.
+    */
+   NIR_PASS_V(nir, nir_opt_idiv_const, 16);
+
    nir_lower_idiv_options idiv_options = {
       .allow_fp16 = true,
    };