Mesa (staging/22.1): spirv: Handle Op*MulExtended for non-32-bit types

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 27 19:30:40 UTC 2022


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

Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date:   Wed Apr 20 11:37:19 2022 -0500

spirv: Handle Op*MulExtended for non-32-bit types

Fixes: 58bcebd987b7 ("spirv: Allow [i/u]mulExtended to use new nir opcode")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6306
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16060>
(cherry picked from commit ef9d97ec1f9d9834db3066b5a7ec67ce6d4ecd86)

---

 .pick_status.json            |  2 +-
 src/compiler/spirv/vtn_alu.c | 22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 0e8ffb84df4..cc8342e9489 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -661,7 +661,7 @@
         "description": "spirv: Handle Op*MulExtended for non-32-bit types",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "58bcebd987b7c4e7d741f42699d34b8189ab9e79"
     },
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
index a9bdb4c3cf1..6fd7a05afc2 100644
--- a/src/compiler/spirv/vtn_alu.c
+++ b/src/compiler/spirv/vtn_alu.c
@@ -530,17 +530,27 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
 
    case SpvOpUMulExtended: {
       vtn_assert(glsl_type_is_struct_or_ifc(dest_type));
-      nir_ssa_def *umul = nir_umul_2x32_64(&b->nb, src[0], src[1]);
-      dest->elems[0]->def = nir_unpack_64_2x32_split_x(&b->nb, umul);
-      dest->elems[1]->def = nir_unpack_64_2x32_split_y(&b->nb, umul);
+      if (src[0]->bit_size == 32) {
+         nir_ssa_def *umul = nir_umul_2x32_64(&b->nb, src[0], src[1]);
+         dest->elems[0]->def = nir_unpack_64_2x32_split_x(&b->nb, umul);
+         dest->elems[1]->def = nir_unpack_64_2x32_split_y(&b->nb, umul);
+      } else {
+         dest->elems[0]->def = nir_imul(&b->nb, src[0], src[1]);
+         dest->elems[1]->def = nir_umul_high(&b->nb, src[0], src[1]);
+      }
       break;
    }
 
    case SpvOpSMulExtended: {
       vtn_assert(glsl_type_is_struct_or_ifc(dest_type));
-      nir_ssa_def *smul = nir_imul_2x32_64(&b->nb, src[0], src[1]);
-      dest->elems[0]->def = nir_unpack_64_2x32_split_x(&b->nb, smul);
-      dest->elems[1]->def = nir_unpack_64_2x32_split_y(&b->nb, smul);
+      if (src[0]->bit_size == 32) {
+         nir_ssa_def *umul = nir_imul_2x32_64(&b->nb, src[0], src[1]);
+         dest->elems[0]->def = nir_unpack_64_2x32_split_x(&b->nb, umul);
+         dest->elems[1]->def = nir_unpack_64_2x32_split_y(&b->nb, umul);
+      } else {
+         dest->elems[0]->def = nir_imul(&b->nb, src[0], src[1]);
+         dest->elems[1]->def = nir_imul_high(&b->nb, src[0], src[1]);
+      }
       break;
    }
 



More information about the mesa-commit mailing list