[llvm] [LoopPeel] Remove known trip count restriction when peeling last. (PR #140792)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 16:12:19 PDT 2025
================
@@ -360,12 +357,17 @@ bool llvm::canPeelLastIteration(const Loop &L, ScalarEvolution &SE) {
/// is known at the second-to-last.
static bool shouldPeelLastIteration(Loop &L, CmpPredicate Pred,
const SCEVAddRecExpr *LeftAR,
- const SCEV *RightSCEV,
- ScalarEvolution &SE) {
+ const SCEV *RightSCEV, ScalarEvolution &SE,
+ const TargetTransformInfo &TTI) {
if (!canPeelLastIteration(L, SE))
return false;
const SCEV *BTC = SE.getBackedgeTakenCount(&L);
+ SCEVExpander Expander(SE, L.getHeader()->getDataLayout(), "loop-peel");
+ if (!SE.isKnownNonZero(BTC) && Expander.isHighCostExpansion(BTC, &L, SCEVCheapExpansionBudget, &TTI,
----------------
efriedma-quic wrote:
Should this use getExitCount() instead of getBackedgeTakenCount()? Peeling shouldn't care if there's an early exit from some other block.
https://github.com/llvm/llvm-project/pull/140792
More information about the llvm-commits
mailing list