Module: Mesa
Branch: staging/23.0
Commit: 7fa4eb305a139b1067fe334876270a98327de6c3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fa4eb305a139b1067fe334876270a98327de6c3

Author: Lionel Landwerlin <[email protected]>
Date:   Tue Mar  7 13:08:36 2023 +0200

intel/fs: fix nir_opt_peephole_ffma max vec assumption

There can be larger vec than vec4.

Signed-off-by: Lionel Landwerlin <[email protected]>
Cc: mesa-stable
Reviewed-by: Marcin Ĺšlusarz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21782>
(cherry picked from commit 18bdc7145982d9188d1141f0dc19467db7cb3b34)

---

 .pick_status.json                              |  2 +-
 src/intel/compiler/brw_nir_opt_peephole_ffma.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 5b4abab6bd6..44f2aaa9eb1 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -6268,7 +6268,7 @@
         "description": "intel/fs: fix nir_opt_peephole_ffma max vec 
assumption",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/intel/compiler/brw_nir_opt_peephole_ffma.c 
b/src/intel/compiler/brw_nir_opt_peephole_ffma.c
index ce8d6376055..2a39a22c5dc 100644
--- a/src/intel/compiler/brw_nir_opt_peephole_ffma.c
+++ b/src/intel/compiler/brw_nir_opt_peephole_ffma.c
@@ -68,9 +68,9 @@ are_all_uses_fadd(nir_ssa_def *def)
 
 static nir_alu_instr *
 get_mul_for_src(nir_alu_src *src, unsigned num_components,
-                uint8_t swizzle[4], bool *negate, bool *abs)
+                uint8_t *swizzle, bool *negate, bool *abs)
 {
-   uint8_t swizzle_tmp[4];
+   uint8_t swizzle_tmp[NIR_MAX_VEC_COMPONENTS];
    assert(src->src.is_ssa && !src->abs && !src->negate);
 
    nir_instr *instr = src->src.ssa->parent_instr;
@@ -133,7 +133,7 @@ get_mul_for_src(nir_alu_src *src, unsigned num_components,
     *   Expected output swizzle = zyxx
     *   If we reuse swizzle in the loop, then output swizzle would be zyzz.
     */
-   memcpy(swizzle_tmp, swizzle, 4*sizeof(uint8_t));
+   memcpy(swizzle_tmp, swizzle, NIR_MAX_VEC_COMPONENTS*sizeof(uint8_t));
    for (int i = 0; i < num_components; i++)
       swizzle[i] = swizzle_tmp[src->swizzle[i]];
 
@@ -189,10 +189,10 @@ brw_nir_opt_peephole_ffma_instr(nir_builder *b,
       return false;
 
    nir_alu_instr *mul;
-   uint8_t add_mul_src, swizzle[4];
+   uint8_t add_mul_src, swizzle[NIR_MAX_VEC_COMPONENTS];
    bool negate, abs;
    for (add_mul_src = 0; add_mul_src < 2; add_mul_src++) {
-      for (unsigned i = 0; i < 4; i++)
+      for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; i++)
          swizzle[i] = i;
 
       negate = false;

Reply via email to