[llvm] [LoopVectorize] Perform loop versioning for some early exit loops (PR #120603)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 09:15:12 PST 2025
================
@@ -1735,15 +1772,18 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
assert(LatchBB->getUniquePredecessor() == SingleUncountableEdge->first &&
"Expected latch predecessor to be the early exiting block");
- // TODO: Handle loops that may fault.
Predicates.clear();
- if (!isDereferenceableReadOnlyLoop(TheLoop, PSE.getSE(), DT, AC,
- &Predicates)) {
- reportVectorizationFailure(
- "Loop may fault",
- "Cannot vectorize potentially faulting early exit loop",
- "PotentiallyFaultingEarlyExitLoop", ORE, TheLoop);
- return false;
+ SmallVector<LoadInst *, 4> Loads;
+ if (!isDereferenceableReadOnlyLoop(TheLoop, PSE.getSE(), DT, AC, &Predicates,
+ &Loads)) {
+ if (!TTI->getMinPageSize() || !analyzePotentiallyFaultingLoads(&Loads)) {
+ reportVectorizationFailure(
----------------
paulwalker-arm wrote:
What happens now for the situation where the loop is not read only? Previously we would have bailed but now that fact looks ignored?
Is it possible that `isDereferenceableReadOnlyLoop` needs a more complex return along the lines of "yes, no, yes if alignment is proven"? This would means we can bail faster for loops that are clearly not read only.
Perhaps the LoopVectorize has just outgrown `isDereferenceableReadOnlyLoop` and it needs to implement something else that better fits its requirements?
https://github.com/llvm/llvm-project/pull/120603
More information about the llvm-commits
mailing list