[llvm] [LV] Add support for speculative loads in loops that may fault (PR #151300)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 30 06:05:40 PDT 2025


================
@@ -1769,15 +1770,61 @@ 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> NonDerefLoads;
----------------
alexey-bataev wrote:

Make a separate function for this

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


More information about the llvm-commits mailing list