Skip to content

Commit 5a1311d

Browse files
authored
[LAA] Strip isNoWrapGEP: dead code (NFC) (#140308)
isNoWrap is the only caller of isNoWrapGEP, and it has subsuming check on the GEP immediately after.
1 parent 97dee78 commit 5a1311d

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

llvm/lib/Analysis/LoopAccessAnalysis.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,6 @@ getStrideFromAddRec(const SCEVAddRecExpr *AR, const Loop *Lp, Type *AccessTy,
851851
return Stride;
852852
}
853853

854-
static bool isNoWrapGEP(Value *Ptr, PredicatedScalarEvolution &PSE,
855-
const Loop *L);
856-
857854
/// Check whether \p AR is a non-wrapping AddRec. If \p Ptr is not nullptr, use
858855
/// informating from the IR pointer value to determine no-wrap.
859856
static bool isNoWrap(PredicatedScalarEvolution &PSE, const SCEVAddRecExpr *AR,
@@ -866,11 +863,6 @@ static bool isNoWrap(PredicatedScalarEvolution &PSE, const SCEVAddRecExpr *AR,
866863
if (Ptr && PSE.hasNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW))
867864
return true;
868865

869-
// The address calculation must not wrap. Otherwise, a dependence could be
870-
// inverted.
871-
if (Ptr && isNoWrapGEP(Ptr, PSE, L))
872-
return true;
873-
874866
// An nusw getelementptr that is an AddRec cannot wrap. If it would wrap,
875867
// the distance between the previously accessed location and the wrapped
876868
// location will be larger than half the pointer index type space. In that
@@ -1468,49 +1460,6 @@ void AccessAnalysis::processMemAccesses() {
14681460
}
14691461
}
14701462

1471-
/// Check whether \p Ptr is non-wrapping GEP.
1472-
static bool isNoWrapGEP(Value *Ptr, PredicatedScalarEvolution &PSE,
1473-
const Loop *L) {
1474-
// Scalar evolution does not propagate the non-wrapping flags to values that
1475-
// are derived from a non-wrapping induction variable because non-wrapping
1476-
// could be flow-sensitive.
1477-
//
1478-
// Look through the potentially overflowing instruction to try to prove
1479-
// non-wrapping for the *specific* value of Ptr.
1480-
1481-
// The arithmetic implied by an nusw GEP can't overflow.
1482-
const auto *GEP = dyn_cast<GetElementPtrInst>(Ptr);
1483-
if (!GEP || !GEP->hasNoUnsignedSignedWrap())
1484-
return false;
1485-
1486-
// Make sure there is only one non-const index and analyze that.
1487-
Value *NonConstIndex = nullptr;
1488-
for (Value *Index : GEP->indices())
1489-
if (!isa<ConstantInt>(Index)) {
1490-
if (NonConstIndex)
1491-
return false;
1492-
NonConstIndex = Index;
1493-
}
1494-
if (!NonConstIndex)
1495-
// The recurrence is on the pointer, ignore for now.
1496-
return false;
1497-
1498-
// The index in GEP is signed. It is non-wrapping if it's derived from a NSW
1499-
// AddRec using a NSW operation.
1500-
if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(NonConstIndex))
1501-
if (OBO->hasNoSignedWrap() &&
1502-
// Assume constant for other the operand so that the AddRec can be
1503-
// easily found.
1504-
isa<ConstantInt>(OBO->getOperand(1))) {
1505-
const SCEV *OpScev = PSE.getSCEV(OBO->getOperand(0));
1506-
1507-
if (auto *OpAR = dyn_cast<SCEVAddRecExpr>(OpScev))
1508-
return OpAR->getLoop() == L && OpAR->getNoWrapFlags(SCEV::FlagNSW);
1509-
}
1510-
1511-
return false;
1512-
}
1513-
15141463
/// Check whether the access through \p Ptr has a constant stride.
15151464
std::optional<int64_t>
15161465
llvm::getPtrStride(PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,

0 commit comments

Comments
 (0)