[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


================
@@ -195,9 +207,14 @@ loop.end:
     assert(Header->getName() == "loop");
     Loop *L = LI.getLoopFor(Header);
 
-    return isDereferenceableReadOnlyLoop(L, &SE, &DT, &AC);
+    SmallVector<LoadInst *, 4> NonDerefLoads;
+    if (FFLI)
+      return isLoopSafeWithLoadOnlyFaults(L, &SE, &DT, &AC, &NonDerefLoads) &&
+             (NonDerefLoads.size() == 1) && (NonDerefLoads[0] == FFLI);
+    return isLoopSafeWithLoadOnlyFaults(L, &SE, &DT, &AC, &NonDerefLoads) &&
+           NonDerefLoads.empty();
----------------
lukel97 wrote:

It's probably easier to just pass in a SmallVector as an argument to the lambda and pass it directly to `isLoopSafeWithLoadOnlyFaults`, and check the contents of it after the ASSERT_TRUE?

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


More information about the llvm-commits mailing list