-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AIEX] Simplify AIEClusterBaseAddress pass #237
Conversation
andcarminati
commented
Nov 15, 2024
- Including a more generic chaining algorithm.
QoR results: Core Compute Cycle Count:
PM Size effect: -0.09% (basically unaffected). |
for (auto RegSet : RegPtrUseMap) { | ||
|
||
SmallVector<MachineInstr *, 8> &Instrs = RegSet.second; | ||
// Chaining aceptance criteria. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit acceptance
return true; | ||
|
||
// If the base reg is used in any of the successive MBBs, then we don't | ||
// want to chain the corresponding ptr adds. Since that would introduce a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit , since (since is a conjunctive of sub-sentences)
MINext->getOperand(2).getReg(), *MRI); | ||
|
||
// Evaluate if we should restart the chain from the base | ||
// pointer. This is necessary whenwe deal with unknonw offsets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: whenwe
, unknonw
8a8b895
to
ef3b592
Compare
@@ -71,6 +71,10 @@ static cl::opt<unsigned> StackAddrSpace( | |||
cl::desc("Specify the addrspace where the stack is allocated " | |||
"(5: Bank A, 6: Bank B, 7: Bank C, 8: Bank D)")); | |||
|
|||
static cl::opt<bool> EnableAddressChaining("aie-address-chaining", cl::Hidden, | |||
cl::init(true), | |||
cl::desc("Enable ptradd chaining.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
Regarding the |
bool processBasicBlock(MachineBasicBlock &MBB, MachineRegisterInfo &MRI, | ||
MachineIRBuilder &MIB, | ||
MachineRegisterInfo *MRI = nullptr; | ||
MachineDominatorTree *DT = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could those be const?
// Get all candidates, i.e. groups of G_PTR_ADDs in the same | ||
// basic block that shares the same input pointer. | ||
void getChainingCandidates(MachineBasicBlock &MBB, | ||
RegToPtrAddMap &RegPtrUseMap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing this to RegToPtrAddMap getChainingCandidates(MachineBasicBlock &MBB)
? This makes it clearer what comes out of this function?
@@ -136,242 +117,152 @@ class AIEClusterBaseAddress : public MachineFunctionPass { | |||
|
|||
StringRef getPassName() const override { return AIE_CLUSTER_BASE_ADDRESS; } | |||
|
|||
using RegToPtrAddMap = std::map<Register, SmallVector<MachineInstr *, 8>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Just RegUseMap
?
bool Changed = false; | ||
|
||
// Get all G_PTR_ADDs that use the same pointer. | ||
getChainingCandidates(MBB, RegPtrUseMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit: I would rename this to e.g. collectPtrUses()
, because we just collect registers used in ptr_adds, there is not extra processing.
// case, we do not want to chain the addresses, because this would | ||
// introduce a COPY that increases the pressure on PTR registers. | ||
// Create chains, when profitable. | ||
for (auto RegSet : RegPtrUseMap) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto RegAndUses
?
} | ||
|
||
// Find if a register is used in reachable MBBs. | ||
bool isRegUsedInReachableMBBs(MachineBasicBlock *MBB, Register Reg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the previous code in that specific case: std::set<MachineBasicBlock *> ReachableMBBs = findReachableMBBs(MBB);
. Reachability is different from dominance.
auto Entry = ChainedPtrAdds.find(&MI); | ||
if (Entry == ChainedPtrAdds.end()) | ||
// Build a chain (or set of chains) of G_PTR_ADDs. We consider as | ||
// chain a linear sequence of linked G_PTR_ADDs, tied no output and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: tied to?
ef3b592
to
8f2e71d
Compare
Hi @gbossu, all your comments were addressed. Thank you very much! |
* Including a more generic chaining algorithm.
8f2e71d
to
d4115b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice simplification!
I'm not concerned about the Floor_aie2_0
regression, we'll recover that by using the post-pipeliner.