diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -3022,8 +3022,8 @@ "Invalid cast"); assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast"); assert((!Ty->isVectorTy() || - cast(Ty)->getNumElements() == - cast(S->getType())->getNumElements()) && + cast(Ty)->getElementCount() == + cast(S->getType())->getElementCount()) && "Invalid cast"); if (Ty->isIntOrIntVectorTy()) @@ -3041,8 +3041,8 @@ "Invalid cast"); assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast"); assert((!Ty->isVectorTy() || - cast(Ty)->getNumElements() == - cast(S->getType())->getNumElements()) && + cast(Ty)->getElementCount() == + cast(S->getType())->getElementCount()) && "Invalid cast"); if (Ty->isIntOrIntVectorTy()) diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -368,11 +368,19 @@ Constant *NullV2I32Ptr = Constant::getNullValue(V2Int32PtrTy); auto Inst1 = CastInst::CreatePointerCast(NullV2I32Ptr, V2Int32Ty, "foo", BB); + Constant *NullVScaleV2I32Ptr = Constant::getNullValue(VScaleV2Int32PtrTy); + auto Inst1VScale = CastInst::CreatePointerCast( + NullVScaleV2I32Ptr, VScaleV2Int32Ty, "foo.vscale", BB); + // Second form auto Inst2 = CastInst::CreatePointerCast(NullV2I32Ptr, V2Int32Ty); + auto Inst2VScale = + CastInst::CreatePointerCast(NullVScaleV2I32Ptr, VScaleV2Int32Ty); delete Inst2; + delete Inst2VScale; Inst1->eraseFromParent(); + Inst1VScale->eraseFromParent(); delete BB; }