diff options
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index b1fa5804d74..ae608ebfb56 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -2925,30 +2925,41 @@ ScopInfo::buildIRAccess(Instruction *Inst, Loop *L, Region *R, 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 (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); - if (AllAffineSubcripts && Sizes.size() > 0) { - for (auto V : Sizes) + 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); + } } } |