@@ -214,7 +214,7 @@ static bool
214
214
evaluatePtrAddRecAtMaxBTCWillNotWrap (const SCEVAddRecExpr *AR,
215
215
const SCEV *MaxBTC, const SCEV *EltSize,
216
216
ScalarEvolution &SE, const DataLayout &DL,
217
- AssumptionCache *AC, DominatorTree *DT ) {
217
+ DominatorTree *DT, AssumptionCache *AC ) {
218
218
auto *PointerBase = SE.getPointerBase (AR->getStart ());
219
219
auto *StartPtr = dyn_cast<SCEVUnknown>(PointerBase);
220
220
if (!StartPtr)
@@ -233,23 +233,14 @@ evaluatePtrAddRecAtMaxBTCWillNotWrap(const SCEVAddRecExpr *AR,
233
233
const SCEV *DerefBytesSCEV = SE.getConstant (WiderTy, DerefBytes);
234
234
235
235
// Check if we have a suitable dereferencable assumption we can use.
236
- RetainedKnowledge DerefRK;
237
- if (!StartPtrV->canBeFreed () &&
238
- getKnowledgeForValue (
239
- StartPtrV, {Attribute::Dereferenceable}, *AC,
240
- [&](RetainedKnowledge RK, Instruction *Assume, auto ) {
241
- if (!isValidAssumeForContext (
242
- Assume, L->getLoopPredecessor ()->getTerminator (), DT))
243
- return false ;
244
- if (RK.AttrKind == Attribute::Dereferenceable) {
245
- DerefRK = std::max (DerefRK, RK);
246
- return true ;
247
- }
248
- return false ;
249
- }) &&
250
- DerefRK.ArgValue ) {
251
- DerefBytesSCEV = SE.getUMaxExpr (DerefBytesSCEV,
252
- SE.getConstant (WiderTy, DerefRK.ArgValue ));
236
+ if (!StartPtrV->canBeFreed ()) {
237
+ RetainedKnowledge DerefRK = getKnowledgeValidInContext (
238
+ StartPtrV, {Attribute::Dereferenceable}, *AC,
239
+ L->getLoopPredecessor ()->getTerminator (), DT);
240
+ if (DerefRK) {
241
+ DerefBytesSCEV = SE.getUMaxExpr (
242
+ DerefBytesSCEV, SE.getConstant (WiderTy, DerefRK.ArgValue ));
243
+ }
253
244
}
254
245
255
246
bool IsKnownNonNegative = SE.isKnownNonNegative (Step);
@@ -298,7 +289,7 @@ std::pair<const SCEV *, const SCEV *> llvm::getStartAndEndForAccess(
298
289
const SCEV *MaxBTC, ScalarEvolution *SE,
299
290
DenseMap<std::pair<const SCEV *, Type *>,
300
291
std::pair<const SCEV *, const SCEV *>> *PointerBounds,
301
- AssumptionCache *AC, DominatorTree *DT ) {
292
+ DominatorTree *DT, AssumptionCache *AC ) {
302
293
std::pair<const SCEV *, const SCEV *> *PtrBoundsPair;
303
294
if (PointerBounds) {
304
295
auto [Iter, Ins] = PointerBounds->insert (
@@ -334,7 +325,7 @@ std::pair<const SCEV *, const SCEV *> llvm::getStartAndEndForAccess(
334
325
// separately checks that accesses cannot not wrap, so unsigned max
335
326
// represents an upper bound.
336
327
if (evaluatePtrAddRecAtMaxBTCWillNotWrap (AR, MaxBTC, EltSizeSCEV, *SE, DL,
337
- AC, DT )) {
328
+ DT, AC )) {
338
329
ScEnd = AR->evaluateAtIteration (MaxBTC, *SE);
339
330
} else {
340
331
ScEnd = SE->getAddExpr (
@@ -383,7 +374,7 @@ void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
383
374
const SCEV *BTC = PSE.getBackedgeTakenCount ();
384
375
const auto &[ScStart, ScEnd] = getStartAndEndForAccess (
385
376
Lp, PtrExpr, AccessTy, BTC, SymbolicMaxBTC, PSE.getSE (),
386
- &DC.getPointerBounds (), DC.getAC (), DC.getDT ());
377
+ &DC.getPointerBounds (), DC.getDT (), DC.getAC ());
387
378
assert (!isa<SCEVCouldNotCompute>(ScStart) &&
388
379
!isa<SCEVCouldNotCompute>(ScEnd) &&
389
380
" must be able to compute both start and end expressions" );
@@ -2036,10 +2027,10 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
2036
2027
const SCEV *SymbolicMaxBTC = PSE.getSymbolicMaxBackedgeTakenCount ();
2037
2028
const auto &[SrcStart_, SrcEnd_] =
2038
2029
getStartAndEndForAccess (InnermostLoop, Src, ATy, BTC, SymbolicMaxBTC,
2039
- PSE.getSE (), &PointerBounds, AC, DT );
2030
+ PSE.getSE (), &PointerBounds, DT, AC );
2040
2031
const auto &[SinkStart_, SinkEnd_] =
2041
2032
getStartAndEndForAccess (InnermostLoop, Sink, BTy, BTC, SymbolicMaxBTC,
2042
- PSE.getSE (), &PointerBounds, AC, DT );
2033
+ PSE.getSE (), &PointerBounds, DT, AC );
2043
2034
if (!isa<SCEVCouldNotCompute>(SrcStart_) &&
2044
2035
!isa<SCEVCouldNotCompute>(SrcEnd_) &&
2045
2036
!isa<SCEVCouldNotCompute>(SinkStart_) &&
0 commit comments