[llvm] bce3680 - [LAA] Move logic to compute start and end of a pointer to helper (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 11:37:19 PDT 2024
Author: Florian Hahn
Date: 2024-05-20T19:35:19+01:00
New Revision: bce3680f45b57f6ce745cb7da659f2ece745a1d1
URL: https://github.com/llvm/llvm-project/commit/bce3680f45b57f6ce745cb7da659f2ece745a1d1
DIFF: https://github.com/llvm/llvm-project/commit/bce3680f45b57f6ce745cb7da659f2ece745a1d1.diff
LOG: [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
https://github.com/llvm/llvm-project/pull/92307.
Added:
Modified:
llvm/lib/Analysis/LoopAccessAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 13dec3b1e1b0d..df01ad119a8be 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -203,11 +203,9 @@ RuntimeCheckingPtrGroup::RuntimeCheckingPtrGroup(
///
/// There is no conflict when the intervals are disjoint:
/// NoConflict = (P2.Start >= P1.End) || (P1.Start >= P2.End)
-void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
- Type *AccessTy, bool WritePtr,
- unsigned DepSetId, unsigned ASId,
- PredicatedScalarEvolution &PSE,
- bool NeedsFreeze) {
+static std::pair<const SCEV *, const SCEV *>
+getStartAndEndForAccess(const Loop *Lp, const SCEV *PtrExpr, Type *AccessTy,
+ PredicatedScalarEvolution &PSE) {
ScalarEvolution *SE = PSE.getSE();
const SCEV *ScStart;
@@ -242,10 +240,22 @@ void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
// Add the size of the pointed element to ScEnd.
auto &DL = Lp->getHeader()->getModule()->getDataLayout();
- Type *IdxTy = DL.getIndexType(Ptr->getType());
+ Type *IdxTy = DL.getIndexType(PtrExpr->getType());
const SCEV *EltSizeSCEV = SE->getStoreSizeOfExpr(IdxTy, AccessTy);
ScEnd = SE->getAddExpr(ScEnd, EltSizeSCEV);
+ return {ScStart, ScEnd};
+}
+
+/// Calculate Start and End points of memory access using
+/// getStartAndEndForAccess.
+void RuntimePointerChecking::insert(Loop *Lp, Value *Ptr, const SCEV *PtrExpr,
+ Type *AccessTy, bool WritePtr,
+ unsigned DepSetId, unsigned ASId,
+ PredicatedScalarEvolution &PSE,
+ bool NeedsFreeze) {
+ const auto &[ScStart, ScEnd] =
+ getStartAndEndForAccess(Lp, PtrExpr, AccessTy, PSE);
Pointers.emplace_back(Ptr, ScStart, ScEnd, WritePtr, DepSetId, ASId, PtrExpr,
NeedsFreeze);
}
More information about the llvm-commits
mailing list