[llvm] cc5b07c - [IR] Fix vector.splice verifier scaling by vscale for fixed length vectors (#170807)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 00:49:32 PST 2025


Author: Luke Lau
Date: 2025-12-05T16:49:28+08:00
New Revision: cc5b07c7618538b6065f6793524c10bdb34dd510

URL: https://github.com/llvm/llvm-project/commit/cc5b07c7618538b6065f6793524c10bdb34dd510
DIFF: https://github.com/llvm/llvm-project/commit/cc5b07c7618538b6065f6793524c10bdb34dd510.diff

LOG: [IR] Fix vector.splice verifier scaling by vscale for fixed length vectors (#170807)

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.

Added: 
    

Modified: 
    llvm/lib/IR/Verifier.cpp
    llvm/test/Verifier/invalid-splice.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 439b3859fd3ac..10e6c452680b0 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -6570,7 +6570,8 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
     VectorType *VecTy = cast<VectorType>(Call.getType());
     int64_t Idx = cast<ConstantInt>(Call.getArgOperand(2))->getSExtValue();
     int64_t KnownMinNumElements = VecTy->getElementCount().getKnownMinValue();
-    if (Call.getParent() && Call.getParent()->getParent()) {
+    if (VecTy->isScalableTy() && Call.getParent() &&
+        Call.getParent()->getParent()) {
       AttributeList Attrs = Call.getParent()->getParent()->getAttributes();
       if (Attrs.hasFnAttr(Attribute::VScaleRange))
         KnownMinNumElements *= Attrs.getFnAttrs().getVScaleRangeMin();

diff  --git a/llvm/test/Verifier/invalid-splice.ll b/llvm/test/Verifier/invalid-splice.ll
index 2239386df562f..c34f4d0898aa0 100644
--- a/llvm/test/Verifier/invalid-splice.ll
+++ b/llvm/test/Verifier/invalid-splice.ll
@@ -26,7 +26,7 @@ define <2 x double> @splice_v2f64_idx2(<2 x double> %a, <2 x double> %b) #0 {
 
 ; CHECK: The splice index exceeds the range [-VL, VL-1] where VL is the known minimum number of elements in the vector
 define <2 x double> @splice_v2f64_idx3(<2 x double> %a, <2 x double> %b) #1 {
-  %res = call <2 x double> @llvm.vector.splice.v2f64(<2 x double> %a, <2 x double> %b, i32 4)
+  %res = call <2 x double> @llvm.vector.splice.v2f64(<2 x double> %a, <2 x double> %b, i32 3)
   ret <2 x double> %res
 }
 


        


More information about the llvm-commits mailing list