[llvm] [SPIR-V] Fix incorrect emission of G_SPLAT_VECTOR for fixed vectors (PR #108534)

Vyacheslav Levytskyy via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 04:12:37 PDT 2024


https://github.com/VyacheslavLevytskyy created https://github.com/llvm/llvm-project/pull/108534

This PR replaces MIRBuilder.buildSplatVector() by MIRBuilder.buildSplatBuildVector(), so that we emit G_BUILD_VECTOR instead of G_SPLAT_VECTOR: the latter is incorrect for fixed vectors and is limited to scalable vectors only.

>From d78950daa5dadf9aa1d1587875539c7f4616868e Mon Sep 17 00:00:00 2001
From: "Levytskyy, Vyacheslav" <vyacheslav.levytskyy at intel.com>
Date: Fri, 13 Sep 2024 04:09:47 -0700
Subject: [PATCH] emit G_BUILD_VECTOR instead of G_SPLAT_VECTOR

---
 llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
index 553d86efa3df34..ca3e47a4b78f23 100644
--- a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
@@ -496,7 +496,7 @@ Register SPIRVGlobalRegistry::getOrCreateIntCompositeOrNull(
     assignSPIRVTypeToVReg(SpvType, SpvVecConst, *CurMF);
     DT.add(CA, CurMF, SpvVecConst);
     if (EmitIR) {
-      MIRBuilder.buildSplatVector(SpvVecConst, SpvScalConst);
+      MIRBuilder.buildSplatBuildVector(SpvVecConst, SpvScalConst);
     } else {
       if (Val) {
         auto MIB = MIRBuilder.buildInstr(SPIRV::OpConstantComposite)



More information about the llvm-commits mailing list