Skip to content

Commit

Permalink
[VP] Fix VPintrinsic::getStaticVectorLength for vp.merge|select
Browse files Browse the repository at this point in the history
VPIntrinsic::getStaticVectorLength infers the operational vector length
of a VPIntrinsic instance from a type that is used with the intrinsic.
The function used the mask operand before. Yet, vp.merge|select do not
have a mask operand (in the predicating sense that the other VP
intrinsics are using them - it is a selection mask for them). Fallback
to the return type to fix this.

Reviewed By: kaz7

Differential Revision: https://reviews.llvm.org/D121913
  • Loading branch information
simoll committed Mar 22, 2022
1 parent 51ba13b commit 7de383c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions llvm/include/llvm/IR/VPIntrinsics.def
Expand Up @@ -397,6 +397,11 @@ HELPER_REGISTER_REDUCTION_SEQ_VP(vp_reduce_fmul, VP_REDUCE_FMUL,

///// 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)
Expand Down
7 changes: 6 additions & 1 deletion llvm/lib/IR/IntrinsicInst.cpp
Expand Up @@ -299,7 +299,12 @@ ElementCount VPIntrinsic::getStaticVectorLength() const {
};

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());
}

Expand Down

0 comments on commit 7de383c

Please sign in to comment.