diff --git a/llvm/include/llvm/IR/VPIntrinsics.def b/llvm/include/llvm/IR/VPIntrinsics.def --- a/llvm/include/llvm/IR/VPIntrinsics.def +++ b/llvm/include/llvm/IR/VPIntrinsics.def @@ -397,6 +397,11 @@ ///// Shuffles { +// The mask 'cond' operand of llvm.vp.select and llvm.vp.merge are not reported +// as masks with the BEGIN_REGISTER_VP_* macros. This is because, unlike other +// VP intrinsics, these two have a defined result on lanes where the mask is +// false. +// // llvm.vp.select(cond,on_true,on_false,vlen) BEGIN_REGISTER_VP(vp_select, None, 3, VP_SELECT, -1) VP_PROPERTY_FUNCTIONAL_OPC(Select) diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp --- a/llvm/lib/IR/IntrinsicInst.cpp +++ b/llvm/lib/IR/IntrinsicInst.cpp @@ -299,7 +299,12 @@ }; Value *VPMask = getMaskParam(); - assert(VPMask && "No mask param?"); + if (!VPMask) { + assert((getIntrinsicID() == Intrinsic::vp_merge || + getIntrinsicID() == Intrinsic::vp_select) && + "Unexpected VP intrinsic without mask operand"); + return GetVectorLengthOfType(getType()); + } return GetVectorLengthOfType(VPMask->getType()); }