Mesa (staging/22.1): nir/opt_shrink_vectors: fix re-using of components for vecN

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 6 17:04:12 UTC 2022


Module: Mesa
Branch: staging/22.1
Commit: af9b75331879e14920631187e4347ff22fa907ba
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=af9b75331879e14920631187e4347ff22fa907ba

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Tue Jun 28 11:13:54 2022 +0200

nir/opt_shrink_vectors: fix re-using of components for vecN

Cc: mesa-stable
Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17276>
(cherry picked from commit 862f1eacb2dc68dd099f8c923134ab01b4459538)

---

 .pick_status.json                         | 2 +-
 src/compiler/nir/nir_opt_shrink_vectors.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 84d8ebab4d7..59e19f036a2 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1030,7 +1030,7 @@
         "description": "nir/opt_shrink_vectors: fix re-using of components for vecN",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/compiler/nir/nir_opt_shrink_vectors.c b/src/compiler/nir/nir_opt_shrink_vectors.c
index e61f7831355..61d45462558 100644
--- a/src/compiler/nir/nir_opt_shrink_vectors.c
+++ b/src/compiler/nir/nir_opt_shrink_vectors.c
@@ -120,10 +120,12 @@ opt_shrink_vector(nir_builder *b, nir_alu_instr *instr)
       if (!((mask >> i) & 0x1))
          continue;
 
+      nir_ssa_scalar scalar = nir_get_ssa_scalar(instr->src[i].src.ssa, instr->src[i].swizzle[0]);
+
       /* Try reuse a component with the same value */
       unsigned j;
       for (j = 0; j < num_components; j++) {
-         if (nir_alu_srcs_equal(instr, instr, i, j)) {
+         if (scalar.def == srcs[j].def && scalar.comp == srcs[j].comp) {
             reswizzle[i] = j;
             break;
          }
@@ -131,7 +133,7 @@ opt_shrink_vector(nir_builder *b, nir_alu_instr *instr)
 
       /* Otherwise, just append the value */
       if (j == num_components) {
-         srcs[num_components] = nir_get_ssa_scalar(instr->src[i].src.ssa, instr->src[i].swizzle[0]);
+         srcs[num_components] = scalar;
          reswizzle[i] = num_components++;
       }
    }



More information about the mesa-commit mailing list