[llvm] [LoopVectorize] Perform loop versioning for some early exit loops (PR #120603)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 13 08:36:13 PST 2025
================
@@ -816,15 +816,26 @@ bool llvm::canReplacePointersIfEqual(const Value *From, const Value *To,
bool llvm::isDereferenceableReadOnlyLoop(
Loop *L, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC,
- SmallVectorImpl<const SCEVPredicate *> *Predicates) {
+ SmallVectorImpl<const SCEVPredicate *> *Predicates,
+ SmallVectorImpl<LoadInst *> *NonDerefLoads) {
+ bool Result = true;
for (BasicBlock *BB : L->blocks()) {
for (Instruction &I : *BB) {
if (auto *LI = dyn_cast<LoadInst>(&I)) {
- if (!isDereferenceableAndAlignedInLoop(LI, L, *SE, *DT, AC, Predicates))
+ if (!isDereferenceableAndAlignedInLoop(LI, L, *SE, *DT, AC,
+ Predicates)) {
+ if (!NonDerefLoads)
+ return false;
+ NonDerefLoads->push_back(LI);
+ Result = false;
+ }
+ } else if (I.mayReadFromMemory() || I.mayWriteToMemory() ||
+ I.mayThrow()) {
+ if (!NonDerefLoads)
return false;
- } else if (I.mayReadFromMemory() || I.mayWriteToMemory() || I.mayThrow())
- return false;
+ Result = false;
----------------
david-arm wrote:
Done
https://github.com/llvm/llvm-project/pull/120603
More information about the llvm-commits
mailing list