[llvm] 7de383c - [VP] Fix VPintrinsic::getStaticVectorLength for vp.merge|select
Simon Moll via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 22 03:42:43 PDT 2022
Author: Simon Moll
Date: 2022-03-22T11:41:23+01:00
New Revision: 7de383c892135ac7ecb67460c677aed72efdb76a
URL: https://github.com/llvm/llvm-project/commit/7de383c892135ac7ecb67460c677aed72efdb76a
DIFF: https://github.com/llvm/llvm-project/commit/7de383c892135ac7ecb67460c677aed72efdb76a.diff
LOG: [VP] Fix VPintrinsic::getStaticVectorLength for vp.merge|select
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
Added:
Modified:
llvm/include/llvm/IR/VPIntrinsics.def
llvm/lib/IR/IntrinsicInst.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/VPIntrinsics.def b/llvm/include/llvm/IR/VPIntrinsics.def
index 093232b7837b9..056601a91a6a1 100644
--- a/llvm/include/llvm/IR/VPIntrinsics.def
+++ b/llvm/include/llvm/IR/VPIntrinsics.def
@@ -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)
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 4850e301d943f..ad729b09db6ca 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -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());
}
More information about the llvm-commits
mailing list