From 09e2ecf1c54217c4b6e52339bce269c2050c35c1 Mon Sep 17 00:00:00 2001 From: Stefan Ilic Date: Tue, 3 Dec 2024 10:23:08 +0000 Subject: [PATCH] Iterate basic blocks in reverse order in liveness analysis Makes iteration faster to converge. --- IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp b/IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp index f9c1e446d4fd..cc18757a3d2f 100644 --- a/IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp +++ b/IGC/Compiler/CISACodeGen/IGCLivenessAnalysis.cpp @@ -17,6 +17,7 @@ SPDX-License-Identifier: MIT #include "GenISAIntrinsics/GenIntrinsicInst.h" #include "common/debug/Debug.hpp" #include "common/igc_regkeys.hpp" +#include "llvmWrapper/IR/Function.h" #include #include @@ -232,8 +233,9 @@ void IGCLivenessAnalysisBase::livenessAnalysis(llvm::Function &F, BBSet *StartBB { // Start with adding all BBs to the Worklist // to make sure In set is populated for every BB - for (BasicBlock &BB : F) - Worklist.push(&BB); + for (auto BBIt = IGCLLVM::rbegin(&F); BBIt != IGCLLVM::rend(&F); ++BBIt) { + Worklist.push(&*BBIt); + } } while (!Worklist.empty()) {