Skip to content

Commit f6cfbc9

Browse files
committed
!ifxup adjust comment, move check inside if
1 parent 85cd46d commit f6cfbc9

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ class AccessAnalysis {
928928
/// The LoopInfo of the loop being checked.
929929
const LoopInfo *LI;
930930

931+
/// The dominator tree of the function.
931932
DominatorTree &DT;
932933

933934
/// Sets of potentially dependent accesses - members of one set share an
@@ -1024,23 +1025,24 @@ static bool isNoWrap(PredicatedScalarEvolution &PSE, const SCEVAddRecExpr *AR,
10241025
// the distance between the previously accessed location and the wrapped
10251026
// location will be larger than half the pointer index type space. In that
10261027
// case, the GEP would be poison and any memory access dependent on it would
1027-
// be immediate UB when executed. The reasoning can only be applied if the
1028-
// pointer is dereferenced at least at the last iteration. For now, check if
1029-
// it is dereferenced in every iteration.
1028+
// be immediate UB when executed.
10301029
if (auto *GEP = dyn_cast_if_present<GetElementPtrInst>(Ptr);
1031-
GEP && GEP->hasNoUnsignedSignedWrap() &&
1032-
(L->getHeader() == L->getLoopLatch() ||
1033-
(any_of(GEP->users(), [L, DT](User *U) {
1034-
if (!isa<LoadInst, StoreInst>(U))
1035-
return false;
1036-
BasicBlock *UserBB = cast<Instruction>(U)->getParent();
1037-
if (DT && !LoopAccessInfo::blockNeedsPredication(UserBB, L, DT))
1038-
return true;
1039-
return UserBB == L->getHeader() ||
1040-
(L->getExitingBlock() == L->getLoopLatch() &&
1041-
UserBB == L->getLoopLatch());
1042-
}))))
1043-
return true;
1030+
GEP && GEP->hasNoUnsignedSignedWrap()) {
1031+
// For the above reasoning to apply, the pointer must be dereferenced in
1032+
// every iteration.
1033+
if (L->getHeader() == L->getLoopLatch() ||
1034+
any_of(GEP->users(), [L, DT](User *U) {
1035+
if (!isa<LoadInst, StoreInst>(U))
1036+
return false;
1037+
BasicBlock *UserBB = cast<Instruction>(U)->getParent();
1038+
if (DT && !LoopAccessInfo::blockNeedsPredication(UserBB, L, DT))
1039+
return true;
1040+
return UserBB == L->getHeader() ||
1041+
(L->getExitingBlock() == L->getLoopLatch() &&
1042+
UserBB == L->getLoopLatch());
1043+
}))
1044+
return true;
1045+
}
10441046

10451047
if (!Stride)
10461048
Stride = getStrideFromAddRec(AR, L, AccessTy, Ptr, PSE);

0 commit comments

Comments
 (0)