@@ -203,11 +203,18 @@ RuntimeCheckingPtrGroup::RuntimeCheckingPtrGroup(
203
203
// /
204
204
// / There is no conflict when the intervals are disjoint:
205
205
// / NoConflict = (P2.Start >= P1.End) || (P1.Start >= P2.End)
206
- static std::pair<const SCEV *, const SCEV *>
207
- getStartAndEndForAccess (const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy,
208
- PredicatedScalarEvolution &PSE) {
206
+ static std::pair<const SCEV *, const SCEV *> getStartAndEndForAccess (
207
+ const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy,
208
+ PredicatedScalarEvolution &PSE,
209
+ DenseMap<const SCEV *, std::pair<const SCEV *, const SCEV *>>
210
+ &PointerBounds) {
209
211
ScalarEvolution *SE = PSE.getSE ();
210
212
213
+ auto [Iter, Ins] = PointerBounds.insert (
214
+ {PtrExpr, {SE->getCouldNotCompute (), SE->getCouldNotCompute ()}});
215
+ if (!Ins)
216
+ return Iter->second ;
217
+
211
218
const SCEV *ScStart;
212
219
const SCEV *ScEnd;
213
220
@@ -244,7 +251,8 @@ getStartAndEndForAccess(const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy,
244
251
const SCEV *EltSizeSCEV = SE->getStoreSizeOfExpr (IdxTy, AccessTy);
245
252
ScEnd = SE->getAddExpr (ScEnd, EltSizeSCEV);
246
253
247
- return {ScStart, ScEnd};
254
+ Iter->second = {ScStart, ScEnd};
255
+ return Iter->second ;
248
256
}
249
257
250
258
// / Calculate Start and End points of memory access using
@@ -254,8 +262,8 @@ void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
254
262
unsigned DepSetId, unsigned ASId,
255
263
PredicatedScalarEvolution &PSE,
256
264
bool NeedsFreeze) {
257
- const auto &[ScStart, ScEnd] =
258
- getStartAndEndForAccess ( Lp, PtrExpr, AccessTy, PSE);
265
+ const auto &[ScStart, ScEnd] = getStartAndEndForAccess (
266
+ Lp, PtrExpr, AccessTy, PSE, DC. getPointerBounds () );
259
267
assert (!isa<SCEVCouldNotCompute>(ScStart) &&
260
268
!isa<SCEVCouldNotCompute>(ScEnd) &&
261
269
" must be able to compute both start and end expressions" );
@@ -1964,10 +1972,9 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
1964
1972
if (SE.isLoopInvariant (Src, InnermostLoop) ||
1965
1973
SE.isLoopInvariant (Sink, InnermostLoop)) {
1966
1974
const auto &[SrcStart, SrcEnd] =
1967
- getStartAndEndForAccess (InnermostLoop, Src, ATy, PSE);
1975
+ getStartAndEndForAccess (InnermostLoop, Src, ATy, PSE, PointerBounds );
1968
1976
const auto &[SinkStart, SinkEnd] =
1969
- getStartAndEndForAccess (InnermostLoop, Sink, BTy, PSE);
1970
-
1977
+ getStartAndEndForAccess (InnermostLoop, Sink, BTy, PSE, PointerBounds);
1971
1978
if (!isa<SCEVCouldNotCompute>(SrcStart) &&
1972
1979
!isa<SCEVCouldNotCompute>(SrcEnd) &&
1973
1980
!isa<SCEVCouldNotCompute>(SinkStart) &&
0 commit comments