summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp14
-rw-r--r--llvm/lib/Transforms/Scalar/SROA.cpp9
-rw-r--r--llvm/lib/Transforms/Utils/FunctionComparator.cpp19
3 files changed, 11 insertions, 31 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 1df9ee7a94f..5b0d5e3bc01 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -467,12 +467,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const DataLayout &DL) {
NGV->setAlignment(NewAlign);
}
} else if (SequentialType *STy = dyn_cast<SequentialType>(Ty)) {
- unsigned NumElements = 0;
- if (ArrayType *ATy = dyn_cast<ArrayType>(STy))
- NumElements = ATy->getNumElements();
- else
- NumElements = cast<VectorType>(STy)->getNumElements();
-
+ unsigned NumElements = STy->getNumElements();
if (NumElements > 16 && GV->hasNUsesOrMore(16))
return nullptr; // It's not worth it.
NewGlobals.reserve(NumElements);
@@ -2119,12 +2114,7 @@ static Constant *EvaluateStoreInto(Constant *Init, Constant *Val,
ConstantInt *CI = cast<ConstantInt>(Addr->getOperand(OpNo));
SequentialType *InitTy = cast<SequentialType>(Init->getType());
-
- uint64_t NumElts;
- if (ArrayType *ATy = dyn_cast<ArrayType>(InitTy))
- NumElts = ATy->getNumElements();
- else
- NumElts = InitTy->getVectorNumElements();
+ uint64_t NumElts = InitTy->getNumElements();
// Break up the array into elements.
for (uint64_t i = 0, e = NumElts; i != e; ++i)
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 258e77e9260..1f9d08528ef 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -3222,13 +3222,8 @@ static Type *getTypePartition(const DataLayout &DL, Type *Ty, uint64_t Offset,
Type *ElementTy = SeqTy->getElementType();
uint64_t ElementSize = DL.getTypeAllocSize(ElementTy);
uint64_t NumSkippedElements = Offset / ElementSize;
- if (ArrayType *ArrTy = dyn_cast<ArrayType>(SeqTy)) {
- if (NumSkippedElements >= ArrTy->getNumElements())
- return nullptr;
- } else if (VectorType *VecTy = dyn_cast<VectorType>(SeqTy)) {
- if (NumSkippedElements >= VecTy->getNumElements())
- return nullptr;
- }
+ if (NumSkippedElements >= SeqTy->getNumElements())
+ return nullptr;
Offset -= NumSkippedElements * ElementSize;
// First check if we need to recurse.
diff --git a/llvm/lib/Transforms/Utils/FunctionComparator.cpp b/llvm/lib/Transforms/Utils/FunctionComparator.cpp
index 1cb75b49c01..81a7c4ceffa 100644
--- a/llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -387,12 +387,6 @@ int FunctionComparator::cmpTypes(Type *TyL, Type *TyR) const {
case Type::IntegerTyID:
return cmpNumbers(cast<IntegerType>(TyL)->getBitWidth(),
cast<IntegerType>(TyR)->getBitWidth());
- case Type::VectorTyID: {
- VectorType *VTyL = cast<VectorType>(TyL), *VTyR = cast<VectorType>(TyR);
- if (int Res = cmpNumbers(VTyL->getNumElements(), VTyR->getNumElements()))
- return Res;
- return cmpTypes(VTyL->getElementType(), VTyR->getElementType());
- }
// TyL == TyR would have returned true earlier, because types are uniqued.
case Type::VoidTyID:
case Type::FloatTyID:
@@ -445,12 +439,13 @@ int FunctionComparator::cmpTypes(Type *TyL, Type *TyR) const {
return 0;
}
- case Type::ArrayTyID: {
- ArrayType *ATyL = cast<ArrayType>(TyL);
- ArrayType *ATyR = cast<ArrayType>(TyR);
- if (ATyL->getNumElements() != ATyR->getNumElements())
- return cmpNumbers(ATyL->getNumElements(), ATyR->getNumElements());
- return cmpTypes(ATyL->getElementType(), ATyR->getElementType());
+ case Type::ArrayTyID:
+ case Type::VectorTyID: {
+ auto *STyL = cast<SequentialType>(TyL);
+ auto *STyR = cast<SequentialType>(TyR);
+ if (STyL->getNumElements() != STyR->getNumElements())
+ return cmpNumbers(STyL->getNumElements(), STyR->getNumElements());
+ return cmpTypes(STyL->getElementType(), STyR->getElementType());
}
}
}
OpenPOWER on IntegriCloud