[llvm] [LAA] Rewrite findForkedPointer (NFC) (PR #140298)
Igor Kirillov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 4 06:12:27 PDT 2025
================
@@ -1238,42 +1255,25 @@ bool AccessAnalysis::createCheckForAccess(
DenseMap<Value *, unsigned> &DepSetId, Loop *TheLoop,
unsigned &RunningDepId, unsigned ASId, bool Assume) {
Value *Ptr = Access.getPointer();
+ ScalarEvolution *SE = PSE.getSE();
+ assert(SE->isSCEVable(Ptr->getType()) && "Value is not SCEVable!");
- SmallVector<PointerIntPair<const SCEV *, 1, bool>> TranslatedPtrs =
- findForkedPointer(PSE, StridesMap, Ptr, TheLoop);
- assert(!TranslatedPtrs.empty() && "must have some translated pointers");
-
- /// Check whether all pointers can participate in a runtime bounds check. They
- /// must either be invariant or AddRecs. If ShouldCheckWrap is true, they also
- /// must not wrap.
- for (auto &P : TranslatedPtrs) {
- // The bounds for loop-invariant pointer is trivial.
- if (PSE.getSE()->isLoopInvariant(P.getPointer(), TheLoop))
- continue;
-
- const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(P.getPointer());
- if (!AR && Assume)
- AR = PSE.getAsAddRec(Ptr);
- if (!AR || !AR->isAffine())
- return false;
-
- // If there's only one option for Ptr, look it up after bounds and wrap
- // checking, because assumptions might have been added to PSE.
- if (TranslatedPtrs.size() == 1) {
- AR =
- cast<SCEVAddRecExpr>(replaceSymbolicStrideSCEV(PSE, StridesMap, Ptr));
- P.setPointer(AR);
- }
-
- // When we run after a failing dependency check we have to make sure
- // we don't have wrapping pointers.
- if (!isNoWrap(PSE, AR, TranslatedPtrs.size() == 1 ? Ptr : nullptr, AccessTy,
- TheLoop, Assume)) {
- return false;
- }
- }
+ // Find the ForkedSCEVs, and prepare the runtime-check pointers.
+ SmallVector<PointerIntPair<const SCEV *, 1, bool>> ForkedSCEVs;
+ findForkedSCEVs(SE, TheLoop, Ptr, ForkedSCEVs, MaxForkedSCEVDepth);
+ auto RTCheckPtrs =
+ getRTCheckPtrs(PSE, TheLoop, Ptr, ForkedSCEVs, StridesMap, Assume);
+
+ /// Check whether all pointers can participate in a runtime bounds check: they
+ /// must either be loop-invariant, or an affine AddRec that does not wrap.
----------------
igogo-x86 wrote:
This comment doesn’t match the current behavior of the check
https://github.com/llvm/llvm-project/pull/140298
More information about the llvm-commits
mailing list