[llvm] [MachineLICM] Allow hoisting loads from invariant address (PR #70796)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 9 09:11:33 PST 2023
================
@@ -369,6 +377,36 @@ bool MachineLICMBase::runOnMachineFunction(MachineFunction &MF) {
AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
SmallVector<MachineLoop *, 8> Worklist(MLI->begin(), MLI->end());
+
+ // Initialize `AllowedToHoistLoads' if needed.
+ if (HoistConstLoads) {
+ auto TmpWorklist = Worklist;
+ // Initialize all loops with true values
+ while (!TmpWorklist.empty()) {
+ auto *L = TmpWorklist.pop_back_val();
+ AllowedToHoistLoads[L] = true;
+ TmpWorklist.insert(TmpWorklist.end(), L->getSubLoops().begin(),
+ L->getSubLoops().end());
+ }
+ // Go through all the instructions inside top-level loops and, after finding
+ // one that makes it potentially unsafe to move loads, update load hoisting
+ // information for each loop containing this instruction.
+ for (auto *TopLoop : Worklist) {
----------------
david-arm wrote:
Is it worth moving this loop into a small member function, i.e. something like `determineHoistableLoadLoops`? Not sure that's the best name though!
https://github.com/llvm/llvm-project/pull/70796
More information about the llvm-commits
mailing list