[polly] r247928 - Delinearize multi-dimensional arrays through bitcasts
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 13:16:21 PDT 2015
Author: grosser
Date: Thu Sep 17 15:16:21 2015
New Revision: 247928
URL: http://llvm.org/viewvc/llvm-project?rev=247928&view=rev
Log:
Delinearize multi-dimensional arrays through bitcasts
In some cases instcombine introduces bitcasts that slightly obfuscate the
multi-dimensionality of an array. This patch teaches our fixed-size
delinearization how to look through bitcasts.
Modified:
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=247928&r1=247927&r2=247928&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Sep 17 15:16:21 2015
@@ -2925,30 +2925,41 @@ ScopInfo::buildIRAccess(Instruction *Ins
assert(BasePointer && "Could not find base pointer");
AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
- if (auto *GEP = dyn_cast<GetElementPtrInst>(Address)) {
- std::vector<const SCEV *> Subscripts;
- std::vector<int> Sizes;
- std::tie(Subscripts, Sizes) = getIndexExpressionsFromGEP(GEP, *SE);
- auto BasePtr = GEP->getOperand(0);
-
- std::vector<const SCEV *> SizesSCEV;
-
- bool AllAffineSubcripts = true;
- for (auto Subscript : Subscripts)
- if (!isAffineExpr(R, Subscript, *SE)) {
- AllAffineSubcripts = false;
- break;
- }
+ if (isa<GetElementPtrInst>(Address) || isa<BitCastInst>(Address)) {
+ auto NewAddress = Address;
+ if (auto *BitCast = dyn_cast<BitCastInst>(Address)) {
+ auto Src = BitCast->getOperand(0);
+ auto SrcTy = Src->getType();
+ auto DstTy = BitCast->getType();
+ if (SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits())
+ NewAddress = Src;
+ }
- if (AllAffineSubcripts && Sizes.size() > 0) {
- for (auto V : Sizes)
+ if (auto *GEP = dyn_cast<GetElementPtrInst>(NewAddress)) {
+ std::vector<const SCEV *> Subscripts;
+ std::vector<int> Sizes;
+ std::tie(Subscripts, Sizes) = getIndexExpressionsFromGEP(GEP, *SE);
+ auto BasePtr = GEP->getOperand(0);
+
+ std::vector<const SCEV *> SizesSCEV;
+
+ bool AllAffineSubcripts = true;
+ for (auto Subscript : Subscripts)
+ if (!isAffineExpr(R, Subscript, *SE)) {
+ AllAffineSubcripts = false;
+ break;
+ }
+
+ if (AllAffineSubcripts && Sizes.size() > 0) {
+ for (auto V : Sizes)
+ SizesSCEV.push_back(SE->getSCEV(ConstantInt::get(
+ IntegerType::getInt64Ty(BasePtr->getContext()), V)));
SizesSCEV.push_back(SE->getSCEV(ConstantInt::get(
- IntegerType::getInt64Ty(BasePtr->getContext()), V)));
- SizesSCEV.push_back(SE->getSCEV(ConstantInt::get(
- IntegerType::getInt64Ty(BasePtr->getContext()), Size)));
+ IntegerType::getInt64Ty(BasePtr->getContext()), Size)));
- return IRAccess(Type, BasePointer->getValue(), AccessFunction, Size, true,
- Subscripts, SizesSCEV, Val);
+ return IRAccess(Type, BasePointer->getValue(), AccessFunction, Size,
+ true, Subscripts, SizesSCEV, Val);
+ }
}
}
More information about the llvm-commits
mailing list