1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[NFC][LoopInterchange] Explicitly pass both InnerLoop and OuterLoop to processLoop

This is a split patch of D96644.

Explicitly pass both `InnerLoop` and `OuterLoop` to function `processLoop` to remove the need to swap elements in loop list and allow making loop list an `ArrayRef`.
Also, fix inconsistent spellings of `OuterLoopId` and `Inner Loop Id` in debug log.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D96650
This commit is contained in:
Ta-Wei Tu 2021-02-16 22:16:53 +08:00
parent 2c65ad01b9
commit a51810f529
3 changed files with 8 additions and 10 deletions

View File

@ -516,8 +516,8 @@ struct LoopInterchange {
unsigned SelecLoopId = selectLoopForInterchange(LoopList);
// Move the selected loop outwards to the best possible position.
for (unsigned i = SelecLoopId; i > 0; i--) {
bool Interchanged =
processLoop(LoopList, i, i - 1, LoopNestExit, DependencyMatrix);
bool Interchanged = processLoop(LoopList[i], LoopList[i - 1], i, i - 1,
LoopNestExit, DependencyMatrix);
if (!Interchanged)
return Changed;
// Loops interchanged reflect the same in LoopList
@ -534,13 +534,11 @@ struct LoopInterchange {
return Changed;
}
bool processLoop(LoopVector LoopList, unsigned InnerLoopId,
bool processLoop(Loop *InnerLoop, Loop *OuterLoop, unsigned InnerLoopId,
unsigned OuterLoopId, BasicBlock *LoopNestExit,
std::vector<std::vector<char>> &DependencyMatrix) {
LLVM_DEBUG(dbgs() << "Processing Inner Loop Id = " << InnerLoopId
LLVM_DEBUG(dbgs() << "Processing InnerLoopId = " << InnerLoopId
<< " and OuterLoopId = " << OuterLoopId << "\n");
Loop *InnerLoop = LoopList[InnerLoopId];
Loop *OuterLoop = LoopList[OuterLoopId];
LoopInterchangeLegality LIL(OuterLoop, InnerLoop, SE, ORE);
if (!LIL.canInterchangeLoops(InnerLoopId, OuterLoopId, DependencyMatrix)) {

View File

@ -21,10 +21,10 @@ target triple = "x86_64-unknown-linux-gnu"
;; fn2(T[k]);
;; }
; CHECK: Processing Inner Loop Id = 2 and OuterLoopId = 1
; CHECK: Processing InnerLoopId = 2 and OuterLoopId = 1
; CHECK: Loops interchanged.
; CHECK: Processing Inner Loop Id = 1 and OuterLoopId = 0
; CHECK: Processing InnerLoopId = 1 and OuterLoopId = 0
; CHECK: Not interchanging loops. Cannot prove legality.
@T = internal global [100 x double] zeroinitializer, align 4

View File

@ -13,10 +13,10 @@ target triple = "x86_64-unknown-linux-gnu"
;; for(int k=0;k<100;k++)
;; D[i][k][j] = D[i][k][j]+t;
; CHECK: Processing Inner Loop Id = 2 and OuterLoopId = 1
; CHECK: Processing InnerLoopId = 2 and OuterLoopId = 1
; CHECK: Loops interchanged.
; CHECK: Processing Inner Loop Id = 1 and OuterLoopId = 0
; CHECK: Processing InnerLoopId = 1 and OuterLoopId = 0
; CHECK: Interchanging loops not profitable.
define void @interchange_08(i32 %t){