@@ -183,10 +183,12 @@ class MemoryDepChecker {
183183 MemoryDepChecker (PredicatedScalarEvolution &PSE, AssumptionCache *AC,
184184 DominatorTree *DT, const Loop *L,
185185 const DenseMap<Value *, const SCEV *> &SymbolicStrides,
186- unsigned MaxTargetVectorWidthInBits)
186+ unsigned MaxTargetVectorWidthInBits,
187+ std::optional<ScalarEvolution::LoopGuards> &LoopGuards)
187188 : PSE(PSE), AC(AC), DT(DT), InnermostLoop(L),
188189 SymbolicStrides (SymbolicStrides),
189- MaxTargetVectorWidthInBits(MaxTargetVectorWidthInBits) {}
190+ MaxTargetVectorWidthInBits(MaxTargetVectorWidthInBits),
191+ LoopGuards(LoopGuards) {}
190192
191193 // / Register the location (instructions are given increasing numbers)
192194 // / of a write access.
@@ -373,7 +375,7 @@ class MemoryDepChecker {
373375 PointerBounds;
374376
375377 // / Cache for the loop guards of InnermostLoop.
376- std::optional<ScalarEvolution::LoopGuards> LoopGuards;
378+ std::optional<ScalarEvolution::LoopGuards> & LoopGuards;
377379
378380 // / Check whether there is a plausible dependence between the two
379381 // / accesses.
@@ -531,8 +533,9 @@ class RuntimePointerChecking {
531533 AliasSetId(AliasSetId), Expr(Expr), NeedsFreeze(NeedsFreeze) {}
532534 };
533535
534- RuntimePointerChecking (MemoryDepChecker &DC, ScalarEvolution *SE)
535- : DC(DC), SE(SE) {}
536+ RuntimePointerChecking (MemoryDepChecker &DC, ScalarEvolution *SE,
537+ std::optional<ScalarEvolution::LoopGuards> &LoopGuards)
538+ : DC(DC), SE(SE), LoopGuards(LoopGuards) {}
536539
537540 // / Reset the state of the pointer runtime information.
538541 void reset () {
@@ -646,6 +649,9 @@ class RuntimePointerChecking {
646649 // / Holds a pointer to the ScalarEvolution analysis.
647650 ScalarEvolution *SE;
648651
652+ // / Cache for the loop guards of the loop.
653+ std::optional<ScalarEvolution::LoopGuards> &LoopGuards;
654+
649655 // / Set of run-time checks required to establish independence of
650656 // / otherwise may-aliasing pointers in the loop.
651657 SmallVector<RuntimePointerCheck, 4 > Checks;
@@ -821,6 +827,9 @@ class LoopAccessInfo {
821827
822828 Loop *TheLoop;
823829
830+ // / Cache for the loop guards of TheLoop.
831+ std::optional<ScalarEvolution::LoopGuards> LoopGuards;
832+
824833 // / Determines whether we should generate partial runtime checks when not all
825834 // / memory accesses could be analyzed.
826835 bool AllowPartial;
@@ -938,7 +947,8 @@ LLVM_ABI std::pair<const SCEV *, const SCEV *> getStartAndEndForAccess(
938947 const SCEV *MaxBTC, ScalarEvolution *SE,
939948 DenseMap<std::pair<const SCEV *, Type *>,
940949 std::pair<const SCEV *, const SCEV *>> *PointerBounds,
941- DominatorTree *DT, AssumptionCache *AC);
950+ DominatorTree *DT, AssumptionCache *AC,
951+ std::optional<ScalarEvolution::LoopGuards> &LoopGuards);
942952
943953class LoopAccessInfoManager {
944954 // / The cache.
0 commit comments