@@ -842,9 +842,6 @@ getStrideFromAddRec(const SCEVAddRecExpr *AR, const Loop *Lp, Type *AccessTy,
842842 return Stride;
843843}
844844
845- static bool isNoWrapGEP (Value *Ptr, PredicatedScalarEvolution &PSE,
846- const Loop *L);
847-
848845// / Check whether \p AR is a non-wrapping AddRec. If \p Ptr is not nullptr, use
849846// / informating from the IR pointer value to determine no-wrap.
850847static bool isNoWrap (PredicatedScalarEvolution &PSE, const SCEVAddRecExpr *AR,
@@ -857,11 +854,6 @@ static bool isNoWrap(PredicatedScalarEvolution &PSE, const SCEVAddRecExpr *AR,
857854 if (Ptr && PSE.hasNoOverflow (Ptr, SCEVWrapPredicate::IncrementNUSW))
858855 return true ;
859856
860- // The address calculation must not wrap. Otherwise, a dependence could be
861- // inverted.
862- if (Ptr && isNoWrapGEP (Ptr, PSE, L))
863- return true ;
864-
865857 // An nusw getelementptr that is an AddRec cannot wrap. If it would wrap,
866858 // the distance between the previously accessed location and the wrapped
867859 // location will be larger than half the pointer index type space. In that
@@ -1457,49 +1449,6 @@ void AccessAnalysis::processMemAccesses() {
14571449 }
14581450}
14591451
1460- // / Check whether \p Ptr is non-wrapping GEP.
1461- static bool isNoWrapGEP (Value *Ptr, PredicatedScalarEvolution &PSE,
1462- const Loop *L) {
1463- // Scalar evolution does not propagate the non-wrapping flags to values that
1464- // are derived from a non-wrapping induction variable because non-wrapping
1465- // could be flow-sensitive.
1466- //
1467- // Look through the potentially overflowing instruction to try to prove
1468- // non-wrapping for the *specific* value of Ptr.
1469-
1470- // The arithmetic implied by an nusw GEP can't overflow.
1471- const auto *GEP = dyn_cast<GetElementPtrInst>(Ptr);
1472- if (!GEP || !GEP->hasNoUnsignedSignedWrap ())
1473- return false ;
1474-
1475- // Make sure there is only one non-const index and analyze that.
1476- Value *NonConstIndex = nullptr ;
1477- for (Value *Index : GEP->indices ())
1478- if (!isa<ConstantInt>(Index)) {
1479- if (NonConstIndex)
1480- return false ;
1481- NonConstIndex = Index;
1482- }
1483- if (!NonConstIndex)
1484- // The recurrence is on the pointer, ignore for now.
1485- return false ;
1486-
1487- // The index in GEP is signed. It is non-wrapping if it's derived from a NSW
1488- // AddRec using a NSW operation.
1489- if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(NonConstIndex))
1490- if (OBO->hasNoSignedWrap () &&
1491- // Assume constant for other the operand so that the AddRec can be
1492- // easily found.
1493- isa<ConstantInt>(OBO->getOperand (1 ))) {
1494- const SCEV *OpScev = PSE.getSCEV (OBO->getOperand (0 ));
1495-
1496- if (auto *OpAR = dyn_cast<SCEVAddRecExpr>(OpScev))
1497- return OpAR->getLoop () == L && OpAR->getNoWrapFlags (SCEV::FlagNSW);
1498- }
1499-
1500- return false ;
1501- }
1502-
15031452// / Check whether the access through \p Ptr has a constant stride.
15041453std::optional<int64_t >
15051454llvm::getPtrStride (PredicatedScalarEvolution &PSE, Type *AccessTy, Value *Ptr,
0 commit comments