[llvm] [MachineLICM] Allow hoisting loads from invariant address (PR #70796)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 6 06:13:05 PST 2023
================
@@ -772,6 +779,32 @@ void MachineLICMBase::HoistOutOfLoop(MachineDomTreeNode *HeaderN,
BackTrace.clear();
InitRegPressure(Preheader);
+ // Compute information about whether it is allowed to move load instruction
+ // out of the current loop or one of the inner loops
+ SmallDenseMap<MachineLoop *, bool> AllowedToHoistLoads;
+ if (HoistConstLoads) {
+ SmallVector<MachineLoop *, 4> Worklist{CurLoop};
+
+ while (!Worklist.empty()) {
----------------
david-arm wrote:
I think we already have this worklist in `runOnMachineFunction`:
`SmallVector<MachineLoop *, 8> Worklist(MLI->begin(), MLI->end());`
If you set up the map there instead you can reduce the amount of extra work needed, for example in `runOnMachineFunction` you could do
```
for (auto *Loop : Worklist) {
for (auto &MI : *MBB) {
...
}
}
```
https://github.com/llvm/llvm-project/pull/70796
More information about the llvm-commits
mailing list