[llvm] [LoopPeel] Implement initial peeling off the last loop iteration. (PR #139551)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 11:46:27 PDT 2025


================
@@ -325,19 +326,66 @@ static unsigned peelToTurnInvariantLoadsDerefencebale(Loop &L,
   return 0;
 }
 
+/// Returns true if the last iteration can be peeled off and the condition (Pred
+/// LeftAR, RightSCEV) is known at the last iteration and the inverse condition
+/// is known at the second-to-last. This function also has to make sure the loop
+/// exit condition can be adjusted when peeling and that the loop executes at
+/// least 2 iterations.
+static bool canPeelLastIteration(Loop &L, const SCEVAddRecExpr *LeftAR,
----------------
efriedma-quic wrote:

Should this be a public API, like canPeel?

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


More information about the llvm-commits mailing list