[llvm] [SPIRV] Promote scalar arguments to vector for `OpExtInst` in `generateExtInst` instead of `SPIRVRegularizer` (PR #170155)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 3 00:15:13 PST 2025


================
@@ -1182,16 +1205,37 @@ static bool generateExtInst(const SPIRV::IncomingCall *Call,
                  : SPIRV::OpenCLExtInst::fmax;
   }
 
+  Register ReturnTypeId = GR->getSPIRVTypeID(Call->ReturnType);
+  SmallVector<Register> Arguments;
+  unsigned ResultElementCount =
+      GR->getScalarOrVectorComponentCount(ReturnTypeId);
+  bool MayNeedPromotionToVec =
+      builtinMayNeedPromotionToVec(Number) && ResultElementCount > 1;
+  for (Register Argument : Call->Arguments) {
+    Register PromotedArg = Argument;
+    SPIRVType *ArgumentType = GR->getSPIRVTypeForVReg(Argument);
+    if (MayNeedPromotionToVec && ArgumentType != Call->ReturnType) {
+      PromotedArg = createVirtualRegister(Call->ReturnType, GR, MIRBuilder);
+      auto VecBroadcast = MIRBuilder.buildInstr(SPIRV::OpCompositeConstruct)
----------------
jmmartinez wrote:

I've renamed it to `VecSplat` in the last commit.

https://github.com/llvm/llvm-project/pull/170155


More information about the llvm-commits mailing list