[PATCH] D137060: [SCEV] Make isKnownOnEveryIteration return false if LHS's start value is not available at loop entry

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 01:28:36 PDT 2022


StephenFan created this revision.
StephenFan added reviewers: nikic, fhahn, reames, mkazantsev.
Herald added a subscriber: hiraditya.
Herald added a project: All.
StephenFan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixes https://github.com/llvm/llvm-project/issues/58662


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137060

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp


Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ 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);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137060.471921.patch
Type: text/x-patch
Size: 714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/97fcf58c/attachment.bin>


More information about the llvm-commits mailing list