Skip to content

Commit 09e2ecf

Browse files
stefan-iligcbot
authored andcommitted
Iterate basic blocks in reverse order in liveness analysis
Makes iteration faster to converge.
1 parent 6619878 commit 09e2ecf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SPDX-License-Identifier: MIT
1717
#include "GenISAIntrinsics/GenIntrinsicInst.h"
1818
#include "common/debug/Debug.hpp"
1919
#include "common/igc_regkeys.hpp"
20+
#include "llvmWrapper/IR/Function.h"
2021

2122
#include <fstream>
2223
#include <queue>
@@ -232,8 +233,9 @@ void IGCLivenessAnalysisBase::livenessAnalysis(llvm::Function &F, BBSet *StartBB
232233
{
233234
// Start with adding all BBs to the Worklist
234235
// to make sure In set is populated for every BB
235-
for (BasicBlock &BB : F)
236-
Worklist.push(&BB);
236+
for (auto BBIt = IGCLLVM::rbegin(&F); BBIt != IGCLLVM::rend(&F); ++BBIt) {
237+
Worklist.push(&*BBIt);
238+
}
237239
}
238240

239241
while (!Worklist.empty()) {

0 commit comments

Comments
 (0)