[llvm] [LoopDist] Add some runtime checks for cross partition loads (PR #145623)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 2 05:35:19 PDT 2025


================
@@ -521,6 +521,21 @@ class InstPartitionContainer {
           Partition = -1;
       }
       assert(Partition != -2 && "Pointer not belonging to any partition");
+      // All the store context uses of our address were processed,
+      // Now make sure we don't have cross partition loads.
+      if (RtPtrCheck->Pointers[I].IsWritePtr) {
+        if (Ptr->hasOneUse() || Partition == -1)
+          continue;
+
+        for (User *U : Ptr->users())
+          if (auto *CurLoad = dyn_cast<LoadInst>(U))
+            if (L->contains(CurLoad->getParent()))
+              if (Partition != (int)this->InstToPartitionId[CurLoad]) {
----------------
Meinersbur wrote:

```suggestion
          auto *CurLoad = dyn_cast<LoadInst>(U);
          if (!CurLoad)
            continue; 
          if (!L->contains(CurLoad->getParent()))
            continue;
          if (Partition == (int)this->InstToPartitionId[CurLoad]) 
            continue;
```
[Use Early Exits and continue to Simplify Code](https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code)

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


More information about the llvm-commits mailing list