[llvm] [SelectionDAG] Widen vector math libcalls when no routine is available (PR #218948)

Mattéo Rizza Murgier via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 02:26:27 PDT 2026


================
@@ -2191,12 +2189,23 @@ bool VectorLegalizer::tryExpandVecMathCall(SDNode *Node, RTLIB::Libcall LC,
     if (HasMaskArg && I == E - 1) {
       assert(cast<VectorType>(ParamTy)->getElementType()->isIntegerTy(1) &&
              "unexpected vector mask type");
-      EVT MaskVT = TLI.getSetCCResultType(DAG.getDataLayout(), Ctx, VT);
-      Args.emplace_back(DAG.getBoolConstant(true, DL, MaskVT, VT),
-                        MaskVT.getTypeForEVT(Ctx));
-
+      EVT MaskVT = TLI.getSetCCResultType(DAG.getDataLayout(), Ctx, CallVT);
+      SDValue Mask;
+      if (CallVT == VT) {
+        Mask = DAG.getBoolConstant(true, DL, MaskVT, CallVT);
+      } else {
+        // Only the lanes holding the node's elements need to be active.
+        EVT SubMaskVT = TLI.getSetCCResultType(DAG.getDataLayout(), Ctx, VT);
----------------
matteo-rm wrote:

Updated to only call `getSetCCResultType` on the wide type.

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


More information about the llvm-commits mailing list