summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2016-02-26 16:08:24 +0000
committerMichael Kruse <llvm@meinersbur.de>2016-02-26 16:08:24 +0000
commit37d136e48ef92780fb93ae34eb278893aef42c5f (patch)
tree7eb1b6b2c22c3229b6994bca336bc8d18aba60a9
parent7155be87cb7e3f17337f02e86837a68b97e1cba7 (diff)
downloadbcm5719-llvm-37d136e48ef92780fb93ae34eb278893aef42c5f.tar.gz
bcm5719-llvm-37d136e48ef92780fb93ae34eb278893aef42c5f.zip
Reduce indention. NFC.
The functions buildAccessMultiDimFixed and buildAccessMultiDimParam were refactored from buildMemoryAccess. In their own functions, the control flow can be shortcut and simplified using returns. Suggested-by: etherzhhb llvm-svn: 262029
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp112
1 files changed, 57 insertions, 55 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index bb62f5ce1b7..e48f87c0442 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -3851,52 +3851,54 @@ bool ScopInfo::buildAccessMultiDimFixed(
enum MemoryAccess::AccessType Type =
Inst.isLoad() ? MemoryAccess::READ : MemoryAccess::MUST_WRITE;
- 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 (auto *BitCast = dyn_cast<BitCastInst>(Address)) {
+ auto *Src = BitCast->getOperand(0);
+ auto *SrcTy = Src->getType();
+ auto *DstTy = BitCast->getType();
+ if (SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits())
+ Address = Src;
+ }
- std::vector<const SCEV *> SizesSCEV;
+ auto *GEP = dyn_cast<GetElementPtrInst>(Address);
+ if (!GEP)
+ return false;
- for (auto *Subscript : Subscripts) {
- InvariantLoadsSetTy AccessILS;
- if (!isAffineExpr(R, Subscript, *SE, nullptr, &AccessILS))
- return false;
+ std::vector<const SCEV *> Subscripts;
+ std::vector<int> Sizes;
+ std::tie(Subscripts, Sizes) = getIndexExpressionsFromGEP(GEP, *SE);
+ auto *BasePtr = GEP->getOperand(0);
- for (LoadInst *LInst : AccessILS)
- if (!ScopRIL.count(LInst))
- return false;
- }
+ std::vector<const SCEV *> SizesSCEV;
- if (Sizes.size() > 0) {
- for (auto V : Sizes)
- SizesSCEV.push_back(SE->getSCEV(ConstantInt::get(
- IntegerType::getInt64Ty(BasePtr->getContext()), V)));
+ for (auto *Subscript : Subscripts) {
+ InvariantLoadsSetTy AccessILS;
+ if (!isAffineExpr(R, Subscript, *SE, nullptr, &AccessILS))
+ return false;
- addArrayAccess(Inst, Type, BasePointer->getValue(), ElementType, true,
- Subscripts, SizesSCEV, Val);
- return true;
- }
- }
+ for (LoadInst *LInst : AccessILS)
+ if (!ScopRIL.count(LInst))
+ return false;
}
- return false;
+
+ if (Sizes.empty())
+ return false;
+
+ for (auto V : Sizes)
+ SizesSCEV.push_back(SE->getSCEV(
+ ConstantInt::get(IntegerType::getInt64Ty(BasePtr->getContext()), V)));
+
+ addArrayAccess(Inst, Type, BasePointer->getValue(), ElementType, true,
+ Subscripts, SizesSCEV, Val);
+ return true;
}
bool ScopInfo::buildAccessMultiDimParam(
MemAccInst Inst, Loop *L, Region *R,
const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
const InvariantLoadsSetTy &ScopRIL, const MapInsnToMemAcc &InsnToMemAcc) {
+ if (!PollyDelinearize)
+ return false;
+
Value *Address = Inst.getPointerOperand();
Value *Val = Inst.getValueOperand();
Type *ElementType = Val->getType();
@@ -3912,27 +3914,27 @@ bool ScopInfo::buildAccessMultiDimParam(
AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
auto AccItr = InsnToMemAcc.find(Inst);
- if (PollyDelinearize && AccItr != InsnToMemAcc.end()) {
- std::vector<const SCEV *> Sizes(
- AccItr->second.Shape->DelinearizedSizes.begin(),
- AccItr->second.Shape->DelinearizedSizes.end());
- // Remove the element size. This information is already provided by the
- // ElementSize parameter. In case the element size of this access and the
- // element size used for delinearization differs the delinearization is
- // incorrect. Hence, we invalidate the scop.
- //
- // TODO: Handle delinearization with differing element sizes.
- auto DelinearizedSize =
- cast<SCEVConstant>(Sizes.back())->getAPInt().getSExtValue();
- Sizes.pop_back();
- if (ElementSize != DelinearizedSize)
- scop->invalidate(DELINEARIZATION, Inst->getDebugLoc());
-
- addArrayAccess(Inst, Type, BasePointer->getValue(), ElementType, true,
- AccItr->second.DelinearizedSubscripts, Sizes, Val);
- return true;
- }
- return false;
+ if (AccItr == InsnToMemAcc.end())
+ return false;
+
+ std::vector<const SCEV *> Sizes(
+ AccItr->second.Shape->DelinearizedSizes.begin(),
+ AccItr->second.Shape->DelinearizedSizes.end());
+ // Remove the element size. This information is already provided by the
+ // ElementSize parameter. In case the element size of this access and the
+ // element size used for delinearization differs the delinearization is
+ // incorrect. Hence, we invalidate the scop.
+ //
+ // TODO: Handle delinearization with differing element sizes.
+ auto DelinearizedSize =
+ cast<SCEVConstant>(Sizes.back())->getAPInt().getSExtValue();
+ Sizes.pop_back();
+ if (ElementSize != DelinearizedSize)
+ scop->invalidate(DELINEARIZATION, Inst->getDebugLoc());
+
+ addArrayAccess(Inst, Type, BasePointer->getValue(), ElementType, true,
+ AccItr->second.DelinearizedSubscripts, Sizes, Val);
+ return true;
}
bool ScopInfo::buildAccessMemIntrinsic(
OpenPOWER on IntegriCloud