Mesa (main): radv: call nir_lower_flrp() after the first radv_optimize_nir()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 24 16:37:17 UTC 2021


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

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed Jun 24 17:47:09 2020 +0100

radv: call nir_lower_flrp() after the first radv_optimize_nir()

instead of inside the optimization loop

Totals from 2504 (1.67% of 150170) affected shaders: (GFX10.3)
VGPRs: 162592 -> 162416 (-0.11%); split: -0.12%, +0.01%
CodeSize: 18399756 -> 18383552 (-0.09%); split: -0.10%, +0.01%
MaxWaves: 42654 -> 42748 (+0.22%)
Instrs: 3499404 -> 3497075 (-0.07%); split: -0.08%, +0.01%
Latency: 87087238 -> 87064270 (-0.03%); split: -0.06%, +0.03%
InvThroughput: 21159621 -> 21150546 (-0.04%); split: -0.05%, +0.01%
VClause: 56653 -> 56667 (+0.02%); split: -0.00%, +0.03%
Copies: 226332 -> 226423 (+0.04%); split: -0.15%, +0.19%
Branches: 110027 -> 110025 (-0.00%); split: -0.05%, +0.04%
PreSGPRs: 168087 -> 168076 (-0.01%); split: -0.01%, +0.00%
PreVGPRs: 160814 -> 160705 (-0.07%)

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12061>

---

 src/amd/vulkan/radv_shader.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index cb9e9fd2caf..f12726e4c81 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -117,9 +117,6 @@ radv_optimize_nir(const struct radv_device *device, struct nir_shader *shader,
                   bool optimize_conservatively, bool allow_copies)
 {
    bool progress;
-   unsigned lower_flrp = (shader->options->lower_flrp16 ? 16 : 0) |
-                         (shader->options->lower_flrp32 ? 32 : 0) |
-                         (shader->options->lower_flrp64 ? 64 : 0);
 
    do {
       progress = false;
@@ -162,21 +159,6 @@ radv_optimize_nir(const struct radv_device *device, struct nir_shader *shader,
       NIR_PASS(progress, shader, nir_opt_constant_folding);
       NIR_PASS(progress, shader, nir_opt_algebraic);
 
-      if (lower_flrp != 0) {
-         bool lower_flrp_progress = false;
-         NIR_PASS(lower_flrp_progress, shader, nir_lower_flrp, lower_flrp,
-                  false /* always_precise */);
-         if (lower_flrp_progress) {
-            NIR_PASS(progress, shader, nir_opt_constant_folding);
-            progress = true;
-         }
-
-         /* Nothing should rematerialize any flrps, so we only
-          * need to do this lowering once.
-          */
-         lower_flrp = 0;
-      }
-
       NIR_PASS(progress, shader, nir_opt_undef);
       NIR_PASS(progress, shader, nir_opt_shrink_vectors,
                !device->instance->disable_shrink_image_store);
@@ -696,6 +678,14 @@ radv_shader_compile_to_nir(struct radv_device *device, struct vk_shader_module *
     */
    nir_lower_var_copies(nir);
 
+   unsigned lower_flrp = (nir->options->lower_flrp16 ? 16 : 0) |
+                         (nir->options->lower_flrp32 ? 32 : 0) |
+                         (nir->options->lower_flrp64 ? 64 : 0);
+   if (lower_flrp != 0) {
+      if (nir_lower_flrp(nir, lower_flrp, false /* always_precise */))
+         NIR_PASS_V(nir, nir_opt_constant_folding);
+   }
+
    const nir_opt_access_options opt_access_options = {
       .is_vulkan = true,
       .infer_non_readable = true,



More information about the mesa-commit mailing list