From 37d136e48ef92780fb93ae34eb278893aef42c5f Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Fri, 26 Feb 2016 16:08:24 +0000 Subject: [PATCH] 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 --- polly/lib/Analysis/ScopInfo.cpp | 112 ++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index bb62f5c..e48f87c 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(Address) || isa(Address)) { - auto *NewAddress = Address; - if (auto *BitCast = dyn_cast(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(NewAddress)) { - std::vector Subscripts; - std::vector Sizes; - std::tie(Subscripts, Sizes) = getIndexExpressionsFromGEP(GEP, *SE); - auto *BasePtr = GEP->getOperand(0); + if (auto *BitCast = dyn_cast(Address)) { + auto *Src = BitCast->getOperand(0); + auto *SrcTy = Src->getType(); + auto *DstTy = BitCast->getType(); + if (SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits()) + Address = Src; + } - std::vector SizesSCEV; + auto *GEP = dyn_cast(Address); + if (!GEP) + return false; - for (auto *Subscript : Subscripts) { - InvariantLoadsSetTy AccessILS; - if (!isAffineExpr(R, Subscript, *SE, nullptr, &AccessILS)) - return false; + std::vector Subscripts; + std::vector 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 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 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(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 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(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( -- 2.7.4