[llvm] Optimize AggressiveAntiDepBreaker.cpp::StartBlock() (PR #119951)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 22:30:58 PST 2024
https://github.com/xjtuhu created https://github.com/llvm/llvm-project/pull/119951
Hoist BB->size(), it does not make sense to call it in the inner for loop.
State->UnionGroups(Reg, 0) can be eliminated, because the logic in the constructor of AggressiveAntiDepState is equivalent to unifying all registers to 0.
>From 9fd1e76e34e38481c825c7b4b5cfebfaf01c417a Mon Sep 17 00:00:00 2001
From: Zhengping-amd <luck60 at 126.com>
Date: Sat, 14 Dec 2024 14:25:02 +0800
Subject: [PATCH] Optimize AggressiveAntiDepBreaker.cpp::StartBlock()
Hoist BB->size() and eliminate State->UnionGroups(Reg, 0) in the inner for loop, because the logic in the constructor of AggressiveAntiDepState is equivalent to unifying all registers to 0.
---
llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp b/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
index e40248197c7c7c..30bbe20d518276 100644
--- a/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
+++ b/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
@@ -152,12 +152,12 @@ void AggressiveAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
std::vector<unsigned> &DefIndices = State->GetDefIndices();
// Examine the live-in regs of all successors.
+ unsigned BBSize = BB->size();
for (MachineBasicBlock *Succ : BB->successors())
for (const auto &LI : Succ->liveins()) {
for (MCRegAliasIterator AI(LI.PhysReg, TRI, true); AI.isValid(); ++AI) {
unsigned Reg = *AI;
- State->UnionGroups(Reg, 0);
- KillIndices[Reg] = BB->size();
+ KillIndices[Reg] = BBSize;
DefIndices[Reg] = ~0u;
}
}
@@ -174,8 +174,7 @@ void AggressiveAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
continue;
for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) {
unsigned AliasReg = *AI;
- State->UnionGroups(AliasReg, 0);
- KillIndices[AliasReg] = BB->size();
+ KillIndices[AliasReg] = BBSize;
DefIndices[AliasReg] = ~0u;
}
}
More information about the llvm-commits
mailing list