diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -286,8 +286,6 @@ return; } - const DataLayout &DL = - SinkAR->getLoop()->getHeader()->getModule()->getDataLayout(); SmallVector SrcInsts = DC.getInstructionsForAccess(Src->PointerValue, Src->IsWritePtr); SmallVector SinkInsts = @@ -298,11 +296,10 @@ CanUseDiffCheck = false; return; } + const DataLayout &DL = + SinkAR->getLoop()->getHeader()->getModule()->getDataLayout(); unsigned AllocSize = std::max(DL.getTypeAllocSize(SrcTy), DL.getTypeAllocSize(DstTy)); - IntegerType *IntTy = - IntegerType::get(Src->PointerValue->getContext(), - DL.getPointerSizeInBits(CGI.AddressSpace)); // Only matching constant steps matching the AllocSize are supported at the // moment. This simplifies the difference computation. Can be extended in the @@ -314,6 +311,10 @@ return; } + IntegerType *IntTy = + IntegerType::get(Src->PointerValue->getContext(), + DL.getPointerSizeInBits(CGI.AddressSpace)); + // When counting down, the dependence distance needs to be swapped. if (Step->getValue()->isNegative()) std::swap(SinkAR, SrcAR);