[llvm] [LoopPeel] Ignore assume intrinsics for the mayWriteToMemory check in peelToTurnInvariantLoadsDereferenceable. (PR #171547)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 10 13:17:23 PST 2025


================
@@ -447,7 +447,10 @@ static unsigned peelToTurnInvariantLoadsDereferenceable(Loop &L,
   const DataLayout &DL = L.getHeader()->getDataLayout();
   for (BasicBlock *BB : L.blocks()) {
     for (Instruction &I : *BB) {
-      if (I.mayWriteToMemory())
+      // Don't consider llvm.assume as writing to memory.
+      if (I.mayWriteToMemory() &&
+          !(isa<IntrinsicInst>(I) &&
+            cast<IntrinsicInst>(I).getIntrinsicID() == Intrinsic::assume))
----------------
nikic wrote:

Would it make sense to skip all inaccessiblememonly calls, rather than only assumes? (I'm still not really clear on how/why writing to memory interacts with dereferenceability.)

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


More information about the llvm-commits mailing list