aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index b577f69..7e5fda2 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -160,10 +160,9 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
// If the cast operand is a constant vector, perform the cast by
// operating on each element. In the cast of bitcasts, the element
// count may be mismatched; don't attempt to handle that here.
- if ((isa<ConstantVector>(V) || isa<ConstantDataVector>(V)) &&
- DestTy->isVectorTy() &&
- cast<FixedVectorType>(DestTy)->getNumElements() ==
- cast<FixedVectorType>(V->getType())->getNumElements()) {
+ if (DestTy->isVectorTy() && V->getType()->isVectorTy() &&
+ cast<VectorType>(DestTy)->getElementCount() ==
+ cast<VectorType>(V->getType())->getElementCount()) {
VectorType *DestVecTy = cast<VectorType>(DestTy);
Type *DstEltTy = DestVecTy->getElementType();
// Fast path for splatted constants.
@@ -174,6 +173,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
return ConstantVector::getSplat(
cast<VectorType>(DestTy)->getElementCount(), Res);
}
+ if (isa<ScalableVectorType>(DestTy))
+ return nullptr;
SmallVector<Constant *, 16> res;
Type *Ty = IntegerType::get(V->getContext(), 32);
for (unsigned i = 0,