Skip to content

Commit bce3680

Browse files
committed
[LAA] Move logic to compute start and end of a pointer to helper (NFC).
This allows use at other places, in particular an updated version of #92307.
1 parent 245491a commit bce3680

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,9 @@ RuntimeCheckingPtrGroup::RuntimeCheckingPtrGroup(
203203
///
204204
/// There is no conflict when the intervals are disjoint:
205205
/// NoConflict = (P2.Start >= P1.End) || (P1.Start >= P2.End)
206-
void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
207-
Type *AccessTy, bool WritePtr,
208-
unsigned DepSetId, unsigned ASId,
209-
PredicatedScalarEvolution &PSE,
210-
bool NeedsFreeze) {
206+
static std::pair<const SCEV *, const SCEV *>
207+
getStartAndEndForAccess(const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy,
208+
PredicatedScalarEvolution &PSE) {
211209
ScalarEvolution *SE = PSE.getSE();
212210

213211
const SCEV *ScStart;
@@ -242,10 +240,22 @@ void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
242240

243241
// Add the size of the pointed element to ScEnd.
244242
auto &DL = Lp->getHeader()->getModule()->getDataLayout();
245-
Type *IdxTy = DL.getIndexType(Ptr->getType());
243+
Type *IdxTy = DL.getIndexType(PtrExpr->getType());
246244
const SCEV *EltSizeSCEV = SE->getStoreSizeOfExpr(IdxTy, AccessTy);
247245
ScEnd = SE->getAddExpr(ScEnd, EltSizeSCEV);
248246

247+
return {ScStart, ScEnd};
248+
}
249+
250+
/// Calculate Start and End points of memory access using
251+
/// getStartAndEndForAccess.
252+
void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
253+
Type *AccessTy, bool WritePtr,
254+
unsigned DepSetId, unsigned ASId,
255+
PredicatedScalarEvolution &PSE,
256+
bool NeedsFreeze) {
257+
const auto &[ScStart, ScEnd] =
258+
getStartAndEndForAccess(Lp, PtrExpr, AccessTy, PSE);
249259
Pointers.emplace_back(Ptr, ScStart, ScEnd, WritePtr, DepSetId, ASId, PtrExpr,
250260
NeedsFreeze);
251261
}

0 commit comments

Comments
 (0)