[llvm] [LV] Add initial legality checks for loops with unbound loads. (PR #152422)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 01:06:24 PDT 2025
================
@@ -856,16 +856,19 @@ bool llvm::canReplacePointersIfEqual(const Value *From, const Value *To,
return isPointerAlwaysReplaceable(From, To, DL);
}
-bool llvm::isDereferenceableReadOnlyLoop(
+bool llvm::isReadOnlyLoopWithSafeOrSpeculativeLoads(
Loop *L, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC,
+ SmallVectorImpl<LoadInst *> *SpeculativeLoads,
SmallVectorImpl<const SCEVPredicate *> *Predicates) {
for (BasicBlock *BB : L->blocks()) {
for (Instruction &I : *BB) {
if (auto *LI = dyn_cast<LoadInst>(&I)) {
if (!isDereferenceableAndAlignedInLoop(LI, L, *SE, *DT, AC, Predicates))
- return false;
- } else if (I.mayReadFromMemory() || I.mayWriteToMemory() || I.mayThrow())
+ SpeculativeLoads->push_back(LI);
----------------
lukel97 wrote:
Do we still need to check that the load is aligned? `RISCVTargetLowering::isLegalSpeculativeLoad` doesn't seem to check it anywhere.
There seems to be quite a bit of logic related to checking alignment in `isDereferenceableAndAlignedInLoop`. Are we sure we don't need it for vleff?
https://github.com/llvm/llvm-project/pull/152422
More information about the llvm-commits
mailing list