Mesa (master): radeonsi: call nir_split_array_vars/shrink_vec_array_vars/opt_find_array_copies

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 5 20:56:39 UTC 2020


Module: Mesa
Branch: master
Commit: 283ad85944b5d9082f0ede7ab41fb353db53fee8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=283ad85944b5d9082f0ede7ab41fb353db53fee8

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Fri Jul  3 22:09:44 2020 -0400

radeonsi: call nir_split_array_vars/shrink_vec_array_vars/opt_find_array_copies

Loosely based on RADV and https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5668

54793 shaders in 33659 tests
Totals:
SGPRS: 2739498 -> 2739474 (-0.00 %)
VGPRS: 1534120 -> 1534256 (0.01 %)
Spilled SGPRs: 2579 -> 2579 (0.00 %)
Spilled VGPRs: 29 -> 29 (0.00 %)
Private memory VGPRs: 2176 -> 256 (-88.24 %)
Scratch size: 2220 -> 288 (-87.03 %) dwords per thread
Code Size: 55572924 -> 55584592 (0.02 %) bytes
LDS: 92 -> 92 (0.00 %) blocks
Max Waves: 966044 -> 966021 (-0.00 %)
Wait states: 0 -> 0 (0.00 %)

Totals from affected shaders:
SGPRS: 7272 -> 7248 (-0.33 %)
VGPRS: 4848 -> 4984 (2.81 %)
Spilled SGPRs: 0 -> 0 (0.00 %)
Spilled VGPRs: 0 -> 0 (0.00 %)
Private memory VGPRs: 2176 -> 256 (-88.24 %)
Scratch size: 2188 -> 256 (-88.30 %) dwords per thread
Code Size: 336332 -> 348000 (3.47 %) bytes
LDS: 18 -> 18 (0.00 %) blocks
Max Waves: 2659 -> 2636 (-0.86 %)
Wait states: 0 -> 0 (0.00 %)

|   PERCENTAGE DELTAS    |  Shaders |    SGPRs |    VGPRs |SpillSGPR |SpillVGPR | PrivVGPR |  Scratch | CodeSize | MaxWaves |    Waits |
|------------------------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|
| 0ad                    |         6|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| alien_isolation        |      2936|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| anholt                 |        10|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| antichamber            |       180|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| batman_arkham_origins  |       589|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| bioshock-infinite      |      1769|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| borderlands2           |      3968|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| borderlands_presequel  |      1326|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| brutal-legend          |       338|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| chromeos               |        86|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| chromium               |         2|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| civilization_beyond..  |       116|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| company_of_heroes2     |       240|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| counter_strike_glob..  |      1142|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| deadcore               |        76|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| deus_ex_mankind_div..  |      1410|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| dirt-showdown          |       533|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| dirt_rally             |       364|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| divinity               |      1052|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| dolphin                |        22|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| dota2                  |      1747|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| europa_universalis_4   |        76|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| f1-2015                |       775|    0.02 %|    0.12 %|    .     |    .     | -100.00 %| -100.00 %|    0.19 %|   -0.04 %|    .     |
| furmark-0.7.0          |         4|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| gimark-0.7.0           |        10|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| glamor                 |        16|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| glmark                 |        96|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| grid_autosport         |      1767|   -0.03 %|    0.17 %|    .     |    .     |  -85.52 %|  -84.44 %|    0.40 %|   -0.03 %|    .     |
| hitman                 |      1413|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| humus-celshading       |         4|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| humus-domino           |         6|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| humus-dynamicbranching |        24|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| humus-hdr              |        10|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| humus-portals          |         2|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| humus-volumetricfog..  |         6|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| left_4_dead_2          |      1762|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| legend_of_grimrock     |       100|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| life_is_strange        |      1296|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| mad_max                |       358|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| many-spheres           |         6|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| metro_2033_redux       |      2670|    .     |    0.02 %|    .     |    .     |    .     |    .     |    .     |   -0.02 %|    .     |
| nexuiz                 |        80|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| payday2                |      1362|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| pixmark-julia-fp32     |         2|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| pixmark-julia-fp64     |         2|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| pixmark-piano-0.7.0    |         2|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| pixmark-volplosion-..  |         2|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| plot3d-0.7.0           |         8|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| portal                 |       474|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| reflections_subway     |        98|    .     |    .     |    .     |    .     |    .     |    .     |    0.02 %|    .     |    .     |
| rocket_league          |       494|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| saints_row_iv          |      1704|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| saints_row_the_third   |       671|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| sauerbraten            |         7|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| scifi_hallway          |        98|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| serious_sam_3_bfe      |       392|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| shadow_of_mordor       |      1410|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| shadow_warrior         |      3956|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| skia                   |      6094|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| sun_temple             |       109|    .     |    .     |    .     |    .     |    .     |    .     |    0.01 %|    .     |    .     |
| supertuxkart           |         4|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| talos_principle        |       324|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| team_fortress_2        |       808|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| tesseract              |       430|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| tessmark-0.7.0         |         6|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| thea                   |       172|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| tomb_raider            |      1448|   -0.02 %|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| total_war_warhammer    |       242|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| ubershaders            |        54|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| ue4_effects_cave       |       290|    .     |    .     |    .     |    .     |    .     |    .     |    0.02 %|    .     |    .     |
| ue4_elemental          |       561|    .     |    .     |    .     |    .     |    .     |    .     |    0.02 %|    .     |    .     |
| ue4_lightroom_inter..  |        64|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| ue4_realistic_rende..  |        86|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| unigine_heaven         |       322|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| unigine_sanctuary      |       264|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| unigine_tropics        |       210|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| unigine_valley         |       278|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| unity                  |        72|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| victor_vran            |      1262|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| warsow                 |       176|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| warzone2100            |         4|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| wasteland2             |        76|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| wavelet-volume         |         4|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| witcher2               |      1040|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| xcom_enemy_within      |      1236|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
| yofrankie              |        82|    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |    .     |
|------------------------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|
| All affected           |       157|   -0.33 %|    2.81 %|    .     |    .     |  -88.24 %|  -88.30 %|    3.47 %|   -0.86 %|    .     |
|------------------------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|
| Total                  |     54793|    .     |    .     |    .     |    .     |  -88.24 %|  -87.03 %|    0.02 %|    .     |    .     |

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5750>

---

 src/gallium/drivers/radeonsi/si_shader_nir.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index ad9ebd65341..19c9332408a 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -739,7 +739,7 @@ void si_nir_scan_shader(const struct nir_shader *nir, struct si_shader_info *inf
    }
 }
 
-static void si_nir_opts(struct nir_shader *nir)
+static void si_nir_opts(struct nir_shader *nir, bool first)
 {
    bool progress;
 
@@ -752,7 +752,24 @@ static void si_nir_opts(struct nir_shader *nir)
       bool lower_alu_to_scalar = false;
       bool lower_phis_to_scalar = false;
 
-      NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
+      if (first) {
+         bool opt_find_array_copies = false;
+
+         NIR_PASS(progress, nir, nir_split_array_vars, nir_var_function_temp);
+         NIR_PASS(lower_alu_to_scalar, nir, nir_shrink_vec_array_vars, nir_var_function_temp);
+         NIR_PASS(opt_find_array_copies, nir, nir_opt_find_array_copies);
+         NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
+
+         /* Call nir_lower_var_copies() to remove any copies introduced
+          * by nir_opt_find_array_copies().
+          */
+         if (opt_find_array_copies)
+            NIR_PASS(progress, nir, nir_lower_var_copies);
+         progress |= opt_find_array_copies;
+      } else {
+         NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
+      }
+
       NIR_PASS(progress, nir, nir_opt_dead_write_vars);
 
       NIR_PASS(lower_alu_to_scalar, nir, nir_opt_trivial_continues);
@@ -920,7 +937,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir)
    NIR_PASS_V(nir, nir_lower_var_copies);
    NIR_PASS_V(nir, nir_lower_pack);
    NIR_PASS_V(nir, nir_opt_access);
-   si_nir_opts(nir);
+   si_nir_opts(nir, true);
 
    /* Lower large variables that are always constant with load_constant
     * intrinsics, which get turned into PC-relative loads from a data
@@ -935,7 +952,7 @@ static void si_lower_nir(struct si_screen *sscreen, struct nir_shader *nir)
 
    changed |= ac_lower_indirect_derefs(nir, sscreen->info.chip_class);
    if (changed)
-      si_nir_opts(nir);
+      si_nir_opts(nir, false);
 
    NIR_PASS_V(nir, nir_lower_bool_to_int32);
    NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);



More information about the mesa-commit mailing list