Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 4 additions & 4 deletions llvm/include/llvm/Analysis/DependenceAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class LLVM_ABI Dependence {

/// getDVEntry - Returns the DV entry associated with a regular or a
/// SameSD level
DVEntry getDVEntry(unsigned Level, bool isSameSD) const;
DVEntry getDVEntry(unsigned Level, bool IsSameSD) const;

/// getDirection - Returns the direction associated with a particular
/// common or SameSD level.
Expand Down Expand Up @@ -234,7 +234,7 @@ class LLVM_ABI Dependence {

/// dumpImp - For debugging purposes. Dumps a dependence to OS with or
/// without considering the SameSD levels.
void dumpImp(raw_ostream &OS, bool SameSD = false) const;
void dumpImp(raw_ostream &OS, bool IsSameSD = false) const;

protected:
Instruction *Src, *Dst;
Expand Down Expand Up @@ -282,8 +282,8 @@ class LLVM_ABI FullDependence final : public Dependence {

/// getDVEntry - Returns the DV entry associated with a regular or a
/// SameSD level.
DVEntry getDVEntry(unsigned Level, bool isSameSD) const {
if (!isSameSD) {
DVEntry getDVEntry(unsigned Level, bool IsSameSD) const {
if (!IsSameSD) {
assert(0 < Level && Level <= Levels && "Level out of range");
return DV[Level - 1];
} else {
Expand Down
44 changes: 24 additions & 20 deletions llvm/lib/Analysis/DependenceAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ static void dumpExampleDependence(raw_ostream &OS, DependenceInfo *DA,
if (NormalizeResults && D->normalize(&SE))
OS << "normalized - ";
D->dump(OS);

unsigned SameSDLevels = D->getSameSDLevels();
if (SameSDLevels > 0) {
OS.indent(2) << "da analyze - assuming " << SameSDLevels
<< " loop level(s) fused: ";
D->dumpImp(OS, true);
OS << "\n";
}

for (unsigned Level = 1; Level <= D->getLevels(); Level++) {
if (D->isSplitable(Level)) {
OS << " da analyze - split level = " << Level;
Expand Down Expand Up @@ -275,7 +284,7 @@ bool Dependence::isAnti() const {
// if no subscript in the source or destination mention the induction
// variable associated with the loop at this level.
// Leave this out of line, so it will serve as a virtual method anchor
bool Dependence::isScalar(unsigned level, bool isSameSD) const { return false; }
bool Dependence::isScalar(unsigned level, bool IsSameSD) const { return false; }

//===----------------------------------------------------------------------===//
// FullDependence methods
Expand Down Expand Up @@ -351,38 +360,38 @@ bool FullDependence::normalize(ScalarEvolution *SE) {

// getDirection - Returns the direction associated with a particular common or
// SameSD level.
unsigned FullDependence::getDirection(unsigned Level, bool isSameSD) const {
return getDVEntry(Level, isSameSD).Direction;
unsigned FullDependence::getDirection(unsigned Level, bool IsSameSD) const {
return getDVEntry(Level, IsSameSD).Direction;
}

// Returns the distance (or NULL) associated with a particular common or
// SameSD level.
const SCEV *FullDependence::getDistance(unsigned Level, bool isSameSD) const {
return getDVEntry(Level, isSameSD).Distance;
const SCEV *FullDependence::getDistance(unsigned Level, bool IsSameSD) const {
return getDVEntry(Level, IsSameSD).Distance;
}

// Returns true if a particular regular or SameSD level is scalar; that is,
// if no subscript in the source or destination mention the induction variable
// associated with the loop at this level.
bool FullDependence::isScalar(unsigned Level, bool isSameSD) const {
return getDVEntry(Level, isSameSD).Scalar;
bool FullDependence::isScalar(unsigned Level, bool IsSameSD) const {
return getDVEntry(Level, IsSameSD).Scalar;
}

// Returns true if peeling the first iteration from this regular or SameSD
// loop level will break this dependence.
bool FullDependence::isPeelFirst(unsigned Level, bool isSameSD) const {
return getDVEntry(Level, isSameSD).PeelFirst;
bool FullDependence::isPeelFirst(unsigned Level, bool IsSameSD) const {
return getDVEntry(Level, IsSameSD).PeelFirst;
}

// Returns true if peeling the last iteration from this regular or SameSD
// loop level will break this dependence.
bool FullDependence::isPeelLast(unsigned Level, bool isSameSD) const {
return getDVEntry(Level, isSameSD).PeelLast;
bool FullDependence::isPeelLast(unsigned Level, bool IsSameSD) const {
return getDVEntry(Level, IsSameSD).PeelLast;
}

// Returns true if splitting loop will break the dependence.
bool FullDependence::isSplitable(unsigned Level, bool isSameSD) const {
return getDVEntry(Level, isSameSD).Splitable;
bool FullDependence::isSplitable(unsigned Level, bool IsSameSD) const {
return getDVEntry(Level, IsSameSD).Splitable;
}

// inSameSDLoops - Returns true if this level is an SameSD level, i.e.,
Expand Down Expand Up @@ -689,11 +698,6 @@ void Dependence::dump(raw_ostream &OS) const {
else if (isInput())
OS << "input";
dumpImp(OS);
unsigned SameSDLevels = getSameSDLevels();
if (SameSDLevels > 0) {
OS << "! / assuming " << SameSDLevels << " loop level(s) fused: ";
dumpImp(OS, true);
}
}
OS << "!\n";

Expand All @@ -706,13 +710,13 @@ void Dependence::dump(raw_ostream &OS) const {

// For debugging purposes. Dumps a dependence to OS with or without considering
// the SameSD levels.
void Dependence::dumpImp(raw_ostream &OS, bool isSameSD) const {
void Dependence::dumpImp(raw_ostream &OS, bool IsSameSD) const {
bool Splitable = false;
unsigned Levels = getLevels();
unsigned SameSDLevels = getSameSDLevels();
bool OnSameSD = false;
unsigned LevelNum = Levels;
if (isSameSD)
if (IsSameSD)
LevelNum += SameSDLevels;
OS << " [";
for (unsigned II = 1; II <= LevelNum; ++II) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define void @p2(i64 %n, ptr %A, ptr %B) nounwind uwtable ssp {
; CHECK-NEXT: da analyze - none!
; CHECK-NEXT: Src: store i64 %i.011, ptr %arrayidx8, align 8 --> Dst: %0 = load i64, ptr %arrayidx17, align 8
; CHECK-NEXT: da analyze - flow [-3 -2]!
; CHECK-NEXT: da analyze - assuming 1 loop level(s) fused: [-3 -2 -1]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit annoying that this gets missed...

; CHECK-NEXT: Src: store i64 %i.011, ptr %arrayidx8, align 8 --> Dst: store i64 %0, ptr %B.addr.24, align 8
; CHECK-NEXT: da analyze - confused!
; CHECK-NEXT: Src: %0 = load i64, ptr %arrayidx17, align 8 --> Dst: %0 = load i64, ptr %arrayidx17, align 8
Expand Down
10 changes: 6 additions & 4 deletions llvm/test/Analysis/DependenceAnalysis/SameSDLoops.ll
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ define void @samebd0(ptr %A) nounwind uwtable ssp {
; CHECK-NEXT: Src: store i64 %i.013, ptr %arrayidx12, align 8 --> Dst: store i64 %i.013, ptr %arrayidx12, align 8
; CHECK-NEXT: da analyze - none!
; CHECK-NEXT: Src: store i64 %i.013, ptr %arrayidx12, align 8 --> Dst: store i64 %l17.04, ptr %arrayidx24, align 8
; CHECK-NEXT: da analyze - output [-4 -3]! / assuming 2 loop level(s) fused: [-4 -3 -3 -1]!
; CHECK-NEXT: da analyze - output [-4 -3]!
; CHECK-NEXT: da analyze - assuming 2 loop level(s) fused: [-4 -3 -3 -1]
; CHECK-NEXT: Src: store i64 %l17.04, ptr %arrayidx24, align 8 --> Dst: store i64 %l17.04, ptr %arrayidx24, align 8
; CHECK-NEXT: da analyze - none!
;
Expand Down Expand Up @@ -96,7 +97,8 @@ define void @samebd1(ptr %A) nounwind uwtable ssp {
; CHECK-NEXT: Src: store i64 %i.03, ptr %arrayidx, align 4 --> Dst: store i64 %i.03, ptr %arrayidx, align 4
; CHECK-NEXT: da analyze - none!
; CHECK-NEXT: Src: store i64 %i.03, ptr %arrayidx, align 4 --> Dst: %0 = load i64, ptr %arrayidx7, align 4
; CHECK-NEXT: da analyze - flow [|<]! / assuming 1 loop level(s) fused: [<=|<]!
; CHECK-NEXT: da analyze - flow [|<]!
; CHECK-NEXT: da analyze - assuming 1 loop level(s) fused: [<=|<]
; CHECK-NEXT: Src: %0 = load i64, ptr %arrayidx7, align 4 --> Dst: %0 = load i64, ptr %arrayidx7, align 4
; CHECK-NEXT: da analyze - none!
;
Expand Down Expand Up @@ -148,7 +150,7 @@ define void @non_samebd0(ptr %A) nounwind uwtable ssp {
; CHECK-NEXT: Src: store i64 %i.013, ptr %arrayidx12, align 8 --> Dst: store i64 %i.013, ptr %arrayidx12, align 8
; CHECK-NEXT: da analyze - none!
; CHECK-NEXT: Src: store i64 %i.013, ptr %arrayidx12, align 8 --> Dst: store i64 %l17.04, ptr %arrayidx24, align 8
; CHECK-NEXT: da analyze - output [-4 -3]!{{$}}
; CHECK-NEXT: da analyze - output [-4 -3]!
; CHECK-NEXT: Src: store i64 %l17.04, ptr %arrayidx24, align 8 --> Dst: store i64 %l17.04, ptr %arrayidx24, align 8
; CHECK-NEXT: da analyze - none!
;
Expand Down Expand Up @@ -227,7 +229,7 @@ define void @non_samebd1(ptr %A) nounwind uwtable ssp {
; CHECK-NEXT: Src: store i64 %i.03, ptr %arrayidx, align 4 --> Dst: store i64 %i.03, ptr %arrayidx, align 4
; CHECK-NEXT: da analyze - none!
; CHECK-NEXT: Src: store i64 %i.03, ptr %arrayidx, align 4 --> Dst: %0 = load i64, ptr %arrayidx7, align 4
; CHECK-NEXT: da analyze - flow [|<]!{{$}}
; CHECK-NEXT: da analyze - flow [|<]!
; CHECK-NEXT: Src: %0 = load i64, ptr %arrayidx7, align 4 --> Dst: %0 = load i64, ptr %arrayidx7, align 4
; CHECK-NEXT: da analyze - none!
;
Expand Down