[llvm] [MachineLICM] Allow hoisting loads from invariant address (PR #70796)

Igor Kirillov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 04:58:04 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(),
----------------
igogo-x86 wrote:

Yeah, at least it is the same behaviour as with IR Loops

https://github.com/llvm/llvm-project/pull/70796


More information about the llvm-commits mailing list