Skip to content
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
849 changes: 486 additions & 363 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.

5 changes: 5 additions & 0 deletions llvm/include/llvm/Analysis/ScalarEvolutionPatternMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H
#define LLVM_ANALYSIS_SCALAREVOLUTIONPATTERNMATCH_H

#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"

namespace llvm {
Expand All @@ -23,6 +24,10 @@ bool match(const SCEV *S, const Pattern &P) {
return P.match(S);
}

template <typename Pattern> bool match(SCEVUse U, const Pattern &P) {
return match(U.getPointer(), P);
}

template <typename Predicate> struct cst_pred_ty : public Predicate {
bool match(const SCEV *S) {
assert((isa<SCEVCouldNotCompute>(S) || !S->getType()->isVectorTy()) &&
Expand Down
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 @@ -1520,7 +1520,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 @@ -500,7 +500,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