[IR] Support scalable vectors in CastInst::CreatePointerCast

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D92482
This commit is contained in:
Cullen Rhodes 2020-12-02 13:21:00 +00:00
parent 3ffbc79357
commit 4167a0259e
2 changed files with 12 additions and 4 deletions

View File

@ -3022,8 +3022,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
"Invalid cast");
assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
assert((!Ty->isVectorTy() ||
cast<FixedVectorType>(Ty)->getNumElements() ==
cast<FixedVectorType>(S->getType())->getNumElements()) &&
cast<VectorType>(Ty)->getElementCount() ==
cast<VectorType>(S->getType())->getElementCount()) &&
"Invalid cast");
if (Ty->isIntOrIntVectorTy())
@ -3041,8 +3041,8 @@ CastInst *CastInst::CreatePointerCast(Value *S, Type *Ty,
"Invalid cast");
assert(Ty->isVectorTy() == S->getType()->isVectorTy() && "Invalid cast");
assert((!Ty->isVectorTy() ||
cast<FixedVectorType>(Ty)->getNumElements() ==
cast<FixedVectorType>(S->getType())->getNumElements()) &&
cast<VectorType>(Ty)->getElementCount() ==
cast<VectorType>(S->getType())->getElementCount()) &&
"Invalid cast");
if (Ty->isIntOrIntVectorTy())

View File

@ -368,11 +368,19 @@ TEST(InstructionsTest, CastInst) {
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;
}