[llvm] [Loads] Check loop-varying pointer in isDereferenceableAndAlignedInLoop. (PR #120962)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 12:15:57 PST 2025
================
@@ -290,6 +290,19 @@ bool llvm::isDereferenceableAndAlignedInLoop(
return isDereferenceableAndAlignedPointer(Ptr, Alignment, EltSize, DL,
HeaderFirstNonPHI, AC, &DT);
+ // If the load executes in a successor of the header, check if the
+ // loop-varying pointer is dereferenceable and aligned at the branch in the
+ // header. This is stricter than necessary and we could instead look for any
+ // block in the loop that executes unconditionally and post-dominates the
+ // block with the access.
+ if (LI->getParent() != L->getHeader() &&
+ L->getExitingBlock() == L->getLoopLatch() &&
----------------
preames wrote:
What if the loop has multiple exiting blocks and multiple latches? (i.e. nullptr == nullptr)
What if Ptr isn't defined in the header?
https://github.com/llvm/llvm-project/pull/120962
More information about the llvm-commits
mailing list