summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2015-08-19 02:56:36 +0000
committerHal Finkel <hfinkel@anl.gov>2015-08-19 02:56:36 +0000
commit0ef2b10f16e4066ee6ee1bbdd759e97ea1065894 (patch)
treeda29f12ed67770e8daccccc75ae699bb71c69b0b
parent46fc8168c23093684f261fe86a2653169084e32b (diff)
downloadbcm5719-llvm-0ef2b10f16e4066ee6ee1bbdd759e97ea1065894.tar.gz
bcm5719-llvm-0ef2b10f16e4066ee6ee1bbdd759e97ea1065894.zip
Fix how DependenceAnalysis calls delinearization
Fix how DependenceAnalysis calls delinearization, mirroring what is done in Delinearization.cpp (mostly by making sure to call getSCEVAtScope before delinearizing, and by removing the unnecessary 'Pairs == 1' check). Patch by Vaivaswatha Nagaraj! llvm-svn: 245408
-rw-r--r--llvm/include/llvm/Analysis/DependenceAnalysis.h5
-rw-r--r--llvm/lib/Analysis/DependenceAnalysis.cpp51
-rw-r--r--llvm/test/Analysis/DependenceAnalysis/GCD.ll14
3 files changed, 43 insertions, 27 deletions
diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h
index b05a72ebb6f..9cd2a1700c6 100644
--- a/llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -926,9 +926,8 @@ namespace llvm {
void updateDirection(Dependence::DVEntry &Level,
const Constraint &CurConstraint) const;
- bool tryDelinearize(const SCEV *SrcSCEV, const SCEV *DstSCEV,
- SmallVectorImpl<Subscript> &Pair,
- const SCEV *ElementSize);
+ bool tryDelinearize(Instruction *Src, Instruction *Dst,
+ SmallVectorImpl<Subscript> &Pair);
public:
static char ID; // Class identification, replacement for typeinfo
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 0e6f222e52e..5add828770f 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -3245,20 +3245,36 @@ void DependenceAnalysis::updateDirection(Dependence::DVEntry &Level,
/// source and destination array references are recurrences on a nested loop,
/// this function flattens the nested recurrences into separate recurrences
/// for each loop level.
-bool DependenceAnalysis::tryDelinearize(const SCEV *SrcSCEV,
- const SCEV *DstSCEV,
- SmallVectorImpl<Subscript> &Pair,
- const SCEV *ElementSize) {
+bool DependenceAnalysis::tryDelinearize(Instruction *Src,
+ Instruction *Dst,
+ SmallVectorImpl<Subscript> &Pair)
+{
+ Value *SrcPtr = getPointerOperand(Src);
+ Value *DstPtr = getPointerOperand(Dst);
+
+ Loop *SrcLoop = LI->getLoopFor(Src->getParent());
+ Loop *DstLoop = LI->getLoopFor(Dst->getParent());
+
+ // Below code mimics the code in Delinearization.cpp
+ const SCEV *SrcAccessFn =
+ SE->getSCEVAtScope(SrcPtr, SrcLoop);
+ const SCEV *DstAccessFn =
+ SE->getSCEVAtScope(DstPtr, DstLoop);
+
const SCEVUnknown *SrcBase =
- dyn_cast<SCEVUnknown>(SE->getPointerBase(SrcSCEV));
+ dyn_cast<SCEVUnknown>(SE->getPointerBase(SrcAccessFn));
const SCEVUnknown *DstBase =
- dyn_cast<SCEVUnknown>(SE->getPointerBase(DstSCEV));
+ dyn_cast<SCEVUnknown>(SE->getPointerBase(DstAccessFn));
if (!SrcBase || !DstBase || SrcBase != DstBase)
return false;
- SrcSCEV = SE->getMinusSCEV(SrcSCEV, SrcBase);
- DstSCEV = SE->getMinusSCEV(DstSCEV, DstBase);
+ const SCEV *ElementSize = SE->getElementSize(Src);
+ if (ElementSize != SE->getElementSize(Dst))
+ return false;
+
+ const SCEV *SrcSCEV = SE->getMinusSCEV(SrcAccessFn, SrcBase);
+ const SCEV *DstSCEV = SE->getMinusSCEV(DstAccessFn, DstBase);
const SCEVAddRecExpr *SrcAR = dyn_cast<SCEVAddRecExpr>(SrcSCEV);
const SCEVAddRecExpr *DstAR = dyn_cast<SCEVAddRecExpr>(DstSCEV);
@@ -3331,7 +3347,6 @@ static void dumpSmallBitVector(SmallBitVector &BV) {
}
#endif
-
// depends -
// Returns NULL if there is no dependence.
// Otherwise, return a Dependence with as many details as possible.
@@ -3426,10 +3441,11 @@ DependenceAnalysis::depends(Instruction *Src, Instruction *Dst,
Pair[0].Dst = DstSCEV;
}
- if (Delinearize && Pairs == 1 && CommonLevels > 1 &&
- tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair, SE->getElementSize(Src))) {
- DEBUG(dbgs() << " delinerized GEP\n");
- Pairs = Pair.size();
+ if (Delinearize && CommonLevels > 1) {
+ if (tryDelinearize(Src, Dst, Pair)) {
+ DEBUG(dbgs() << " delinerized GEP\n");
+ Pairs = Pair.size();
+ }
}
for (unsigned P = 0; P < Pairs; ++P) {
@@ -3851,10 +3867,11 @@ const SCEV *DependenceAnalysis::getSplitIteration(const Dependence &Dep,
Pair[0].Dst = DstSCEV;
}
- if (Delinearize && Pairs == 1 && CommonLevels > 1 &&
- tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair, SE->getElementSize(Src))) {
- DEBUG(dbgs() << " delinerized GEP\n");
- Pairs = Pair.size();
+ if (Delinearize && CommonLevels > 1) {
+ if (tryDelinearize(Src, Dst, Pair)) {
+ DEBUG(dbgs() << " delinerized GEP\n");
+ Pairs = Pair.size();
+ }
}
for (unsigned P = 0; P < Pairs; ++P) {
diff --git a/llvm/test/Analysis/DependenceAnalysis/GCD.ll b/llvm/test/Analysis/DependenceAnalysis/GCD.ll
index 81d05a10cf1..f9749d51bb3 100644
--- a/llvm/test/Analysis/DependenceAnalysis/GCD.ll
+++ b/llvm/test/Analysis/DependenceAnalysis/GCD.ll
@@ -269,10 +269,10 @@ entry:
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd4'
-; DELIN: da analyze - output [* *]!
+; DELIN: da analyze - none!
; DELIN: da analyze - none!
; DELIN: da analyze - confused!
-; DELIN: da analyze - input [* *]!
+; DELIN: da analyze - none!
; DELIN: da analyze - confused!
; DELIN: da analyze - none!
@@ -339,10 +339,10 @@ entry:
; CHECK: da analyze - none!
; DELIN: 'Dependence Analysis' for function 'gcd5'
-; DELIN: da analyze - output [* *]!
-; DELIN: da analyze - flow [<> *]!
+; DELIN: da analyze - none!
+; DELIN: da analyze - flow [> *]!
; DELIN: da analyze - confused!
-; DELIN: da analyze - input [* *]!
+; DELIN: da analyze - none!
; DELIN: da analyze - confused!
; DELIN: da analyze - none!
@@ -410,10 +410,10 @@ entry:
; CHECK: da analyze - output [* *]!
; DELIN: 'Dependence Analysis' for function 'gcd6'
-; DELIN: da analyze - output [* *]!
+; DELIN: da analyze - none!
; DELIN: da analyze - none!
; DELIN: da analyze - confused!
-; DELIN: da analyze - input [* *]!
+; DELIN: da analyze - none!
; DELIN: da analyze - confused!
; DELIN: da analyze - output [* *]!
OpenPOWER on IntegriCloud