diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -10718,7 +10718,11 @@ const SCEVAddRecExpr *LHS, const SCEV *RHS) { const Loop *L = LHS->getLoop(); - return isLoopEntryGuardedByCond(L, Pred, LHS->getStart(), RHS) && + const SCEV *Start = LHS->getStart(); + if (!isAvailableAtLoopEntry(Start, L)) + return false; + + return isLoopEntryGuardedByCond(L, Pred, Start, RHS) && isLoopBackedgeGuardedByCond(L, Pred, LHS->getPostIncExpr(*this), RHS); }