Skip to content

[SCEV] Add option to request use-specific SCEV for a GEP expr (WIP). #91964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: users/fhahn/scevuse
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
825 changes: 463 additions & 362 deletions llvm/include/llvm/Analysis/ScalarEvolution.h

Large diffs are not rendered by default.

287 changes: 154 additions & 133 deletions llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions llvm/lib/Analysis/DependenceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,10 +1250,12 @@ bool DependenceInfo::strongSIVtest(const SCEV *Coeff, const SCEV *SrcConst,
if (const SCEV *UpperBound = collectUpperBound(CurLoop, Delta->getType())) {
LLVM_DEBUG(dbgs() << "\t UpperBound = " << *UpperBound);
LLVM_DEBUG(dbgs() << ", " << *UpperBound->getType() << "\n");
const SCEV *AbsDelta =
SE->isKnownNonNegative(Delta) ? Delta : SE->getNegativeSCEV(Delta);
const SCEV *AbsCoeff =
SE->isKnownNonNegative(Coeff) ? Coeff : SE->getNegativeSCEV(Coeff);
const SCEV *AbsDelta = SE->isKnownNonNegative(Delta)
? Delta
: SE->getNegativeSCEV(Delta).getPointer();
const SCEV *AbsCoeff = SE->isKnownNonNegative(Coeff)
? Coeff
: SE->getNegativeSCEV(Coeff).getPointer();
const SCEV *Product = SE->getMulExpr(UpperBound, AbsCoeff);
if (isKnownPredicate(CmpInst::ICMP_SGT, AbsDelta, Product)) {
// Distance greater than trip count - no dependence
Expand Down Expand Up @@ -1791,8 +1793,9 @@ bool DependenceInfo::weakZeroSrcSIVtest(const SCEV *DstCoeff,
const SCEV *AbsCoeff =
SE->isKnownNegative(ConstCoeff) ?
SE->getNegativeSCEV(ConstCoeff) : ConstCoeff;
const SCEV *NewDelta =
SE->isKnownNegative(ConstCoeff) ? SE->getNegativeSCEV(Delta) : Delta;
const SCEV *NewDelta = SE->isKnownNegative(ConstCoeff)
? SE->getNegativeSCEV(Delta).getPointer()
: Delta;

// check that Delta/SrcCoeff < iteration count
// really check NewDelta < count*AbsCoeff
Expand Down Expand Up @@ -1900,8 +1903,9 @@ bool DependenceInfo::weakZeroDstSIVtest(const SCEV *SrcCoeff,
const SCEV *AbsCoeff =
SE->isKnownNegative(ConstCoeff) ?
SE->getNegativeSCEV(ConstCoeff) : ConstCoeff;
const SCEV *NewDelta =
SE->isKnownNegative(ConstCoeff) ? SE->getNegativeSCEV(Delta) : Delta;
const SCEV *NewDelta = SE->isKnownNegative(ConstCoeff)
? SE->getNegativeSCEV(Delta).getPointer()
: Delta;

// check that Delta/SrcCoeff < iteration count
// really check NewDelta < count*AbsCoeff
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/IVDescriptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ bool InductionDescriptor::isInductionPHI(
return false;

// Check that the PHI is consecutive.
const SCEV *PhiScev = Expr ? Expr : SE->getSCEV(Phi);
const SCEV *PhiScev = Expr ? Expr : SE->getSCEV(Phi).getPointer();
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(PhiScev);

if (!AR) {
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Analysis/LoopCacheAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ bool IndexedReference::isConsecutive(const Loop &L, const SCEV *&Stride,
SE.getNoopOrSignExtend(ElemSize, WiderType));
const SCEV *CacheLineSize = SE.getConstant(Stride->getType(), CLS);

Stride = SE.isKnownNegative(Stride) ? SE.getNegativeSCEV(Stride) : Stride;
Stride = SE.isKnownNegative(Stride) ? SE.getNegativeSCEV(Stride).getPointer()
: Stride;
return SE.isKnownPredicate(ICmpInst::ICMP_ULT, Stride, CacheLineSize);
}

Expand Down
Loading
Loading