Skip to content

Commit d82c8f5

Browse files
committed
[IR] Fix vector.splice verifier scaling by vscale for fixed length vectors
Currently we multiply the known minimum number of elements by vscale even if the vector in question is fixed, so sometimes we miss some fixed vectors with out of bounds indices.
1 parent 65b2793 commit d82c8f5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6570,7 +6570,8 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
65706570
VectorType *VecTy = cast<VectorType>(Call.getType());
65716571
int64_t Idx = cast<ConstantInt>(Call.getArgOperand(2))->getSExtValue();
65726572
int64_t KnownMinNumElements = VecTy->getElementCount().getKnownMinValue();
6573-
if (Call.getParent() && Call.getParent()->getParent()) {
6573+
if (VecTy->isScalableTy() && Call.getParent() &&
6574+
Call.getParent()->getParent()) {
65746575
AttributeList Attrs = Call.getParent()->getParent()->getAttributes();
65756576
if (Attrs.hasFnAttr(Attribute::VScaleRange))
65766577
KnownMinNumElements *= Attrs.getFnAttrs().getVScaleRangeMin();

llvm/test/Verifier/invalid-splice.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ define <2 x double> @splice_v2f64_idx2(<2 x double> %a, <2 x double> %b) #0 {
2626

2727
; CHECK: The splice index exceeds the range [-VL, VL-1] where VL is the known minimum number of elements in the vector
2828
define <2 x double> @splice_v2f64_idx3(<2 x double> %a, <2 x double> %b) #1 {
29-
%res = call <2 x double> @llvm.vector.splice.v2f64(<2 x double> %a, <2 x double> %b, i32 4)
29+
%res = call <2 x double> @llvm.vector.splice.v2f64(<2 x double> %a, <2 x double> %b, i32 3)
3030
ret <2 x double> %res
3131
}
3232

0 commit comments

Comments
 (0)