Skip to content

Commit a2f8269

Browse files
committed
[LoopInterchange] Fix depends() check parameters
1 parent 1a11302 commit a2f8269

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

llvm/lib/Transforms/Scalar/LoopInterchange.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ static bool populateDependencyMatrix(CharMatrix &DepMatrix, unsigned Level,
120120
// Ignore Input dependencies.
121121
if (isa<LoadInst>(Src) && isa<LoadInst>(Dst))
122122
continue;
123+
// Swap if Src is no a store.
124+
if (!isa<StoreInst>(Src))
125+
std::swap(Src, Dst);
123126
// Track Output, Flow, and Anti dependencies.
124127
if (auto D = DI->depends(Src, Dst, true)) {
125128
assert(D->isOrdered() && "Expected an output, flow or anti dep.");

llvm/test/Transforms/LoopInterchange/interchange-s231.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
;; for (int j = 1; j < 256; j++)
1111
;; aa[j][i] = aa[j - 1][i] + bb[j][i];
1212

13-
; CHECK: Found anti dependency between Src and Dst
14-
; CHECK: Src: %1 = load float, ptr %arrayidx10, align 4
15-
; CHECK: Dst: store float %add, ptr %arrayidx18, align 4
13+
; CHECK: Found flow dependency between Src and Dst
14+
; CHECK: Src: store float %add, ptr %arrayidx18, align 4
15+
; CHECK: Dst: %1 = load float, ptr %arrayidx10, align 4
1616
; CHECK: Processing InnerLoopId = 2 and OuterLoopId = 1
17-
; CHECK: Not interchanging loops. Cannot prove legality.
17+
; CHECK: Loops interchanged.
1818

1919
define float @s231() {
2020
entry:

0 commit comments

Comments
 (0)