[llvm] [LV] Add initial legality checks for loops with unbound loads. (PR #152422)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 11 06:34:25 PDT 2025
================
@@ -1760,16 +1760,42 @@ bool LoopVectorizationLegality::isVectorizableEarlyExitLoop() {
assert(LatchBB->getUniquePredecessor() == SingleUncountableExitingBlock &&
"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)) {
+ SmallVector<LoadInst *, 4> NonDerefLoads;
+ bool HasSafeAccess =
+ TTI->supportsSpeculativeLoads()
+ ? isReadOnlyLoopWithSafeOrSpeculativeLoads(
----------------
david-arm wrote:
I think you can just always call `isReadOnlyLoopWithSafeOrSpeculativeLoads`, then do something like:
```
if (!isReadOnlyLoopWithSafeOrSpeculativeLoads() || (NonDerefLoads.size() && !TTI->supportsSpeculativeLoads())) {
report...
return false;
}
```
However, it's probably more complicated than that because I think you need to call `supportsSpeculativeLoads` for every speculative load using the specific loaded memory type.
https://github.com/llvm/llvm-project/pull/152422
More information about the llvm-commits
mailing list