[llvm] [LV] Add initial legality checks for loops with unbound loads. (PR #152422)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 21:44:24 PDT 2025


================
@@ -85,10 +85,11 @@ LLVM_ABI bool isDereferenceableAndAlignedInLoop(
     AssumptionCache *AC = nullptr,
     SmallVectorImpl<const SCEVPredicate *> *Predicates = nullptr);
 
-/// Return true if the loop \p L cannot fault on any iteration and only
-/// contains read-only memory accesses.
-LLVM_ABI bool isDereferenceableReadOnlyLoop(
+/// Returns true if the only potentially faulting operations in loop are loads.
+/// Also collect loads that are not guaranteed to be dereferenceable.
+LLVM_ABI bool isLoopSafeWithLoadOnlyFaults(
----------------
lukel97 wrote:

I think the term safe is a bit misleading because it still might fault. It also might not necessarily contain any loads that fault, e.g. all the loads might be dereferenceable. I think a better name is probably just to say that the loop is read only? That way it's clearer to the caller that they need to check `NonDereferenceableAndAlignedLoads`.

```suggestion
LLVM_ABI bool isReadOnlyLoop(
```

https://github.com/llvm/llvm-project/pull/152422


More information about the llvm-commits mailing list