diff options
author | Craig Topper <craig.topper@sifive.com> | 2025-07-08 13:54:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-08 13:54:11 -0700 |
commit | 6ee87759e3ddcaca0cda3d9fd53e69cff7315c1d (patch) | |
tree | 9c6683b15863785b12238f69a3fadc23b84739ac /llvm/lib/IR/Verifier.cpp | |
parent | d3d77f71aaf46ec705abdf80db37725dd0c03659 (diff) | |
download | llvm-6ee87759e3ddcaca0cda3d9fd53e69cff7315c1d.zip llvm-6ee87759e3ddcaca0cda3d9fd53e69cff7315c1d.tar.gz llvm-6ee87759e3ddcaca0cda3d9fd53e69cff7315c1d.tar.bz2 |
[RISCV][IR] Implement verifier check for llvm.experimental.vp.splice immediate. (#147458)
This applies the same check as llvm.vector.splice which checks that the immediate is in the range [-VL, VL-1] where VL is the minimum vector length. If vscale_range is available, the lower bound is used to increase the known minimum vector length for this check. This ensures the immediate is in range for any possible value of vscale that satisfies the vscale_range.
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 227afe2b..eb747bc 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -6939,20 +6939,44 @@ void Verifier::visitVPIntrinsic(VPIntrinsic &VPI) { break; } } - if (VPI.getIntrinsicID() == Intrinsic::vp_fcmp) { + + switch (VPI.getIntrinsicID()) { + case Intrinsic::vp_fcmp: { auto Pred = cast<VPCmpIntrinsic>(&VPI)->getPredicate(); Check(CmpInst::isFPPredicate(Pred), "invalid predicate for VP FP comparison intrinsic", &VPI); + break; } - if (VPI.getIntrinsicID() == Intrinsic::vp_icmp) { + case Intrinsic::vp_icmp: { auto Pred = cast<VPCmpIntrinsic>(&VPI)->getPredicate(); Check(CmpInst::isIntPredicate(Pred), "invalid predicate for VP integer comparison intrinsic", &VPI); + break; } - if (VPI.getIntrinsicID() == Intrinsic::vp_is_fpclass) { + case Intrinsic::vp_is_fpclass: { auto TestMask = cast<ConstantInt>(VPI.getOperand(1)); Check((TestMask->getZExtValue() & ~static_cast<unsigned>(fcAllFlags)) == 0, "unsupported bits for llvm.vp.is.fpclass test mask"); + break; + } + case Intrinsic::experimental_vp_splice: { + VectorType *VecTy = cast<VectorType>(VPI.getType()); + int64_t Idx = cast<ConstantInt>(VPI.getArgOperand(2))->getSExtValue(); + int64_t KnownMinNumElements = VecTy->getElementCount().getKnownMinValue(); + if (VPI.getParent() && VPI.getParent()->getParent()) { + AttributeList Attrs = VPI.getParent()->getParent()->getAttributes(); + if (Attrs.hasFnAttr(Attribute::VScaleRange)) + KnownMinNumElements *= Attrs.getFnAttrs().getVScaleRangeMin(); + } + Check((Idx < 0 && std::abs(Idx) <= KnownMinNumElements) || + (Idx >= 0 && Idx < KnownMinNumElements), + "The splice index exceeds the range [-VL, VL-1] where VL is the " + "known minimum number of elements in the vector. For scalable " + "vectors the minimum number of elements is determined from " + "vscale_range.", + &VPI); + break; + } } } |