[PATCH] D137060: [IndVars] Forget a SCEV when an instruction has been sunk.

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 2 10:42:13 PDT 2022


StephenFan updated this revision to Diff 472683.
StephenFan retitled this revision from "[SCEV] Make isKnownOnEveryIteration return false if LHS's start value is not available at loop entry" to "[IndVars] Forget a SCEV when an instruction has been sunk.".
StephenFan edited the summary of this revision.
StephenFan added a comment.
Herald added a subscriber: javed.absar.

Change solution.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137060/new/

https://reviews.llvm.org/D137060

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp


Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -1282,6 +1282,7 @@
     MadeAnyChanges = true;
     ToMove->moveBefore(*ExitBlock, InsertPt);
     SE->forgetBlockAndLoopDispositions(ToMove);
+    SE->forgetValue(ToMove);
     if (Done) break;
     InsertPt = ToMove->getIterator();
   }
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.472683.patch
Type: text/x-patch
Size: 1177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221102/129f5044/attachment.bin>


More information about the llvm-commits mailing list