[llvm] [indvars] Update SCEV after eliminating CmpInst of loop latch (PR #207044)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 05:53:43 PDT 2026


================
@@ -266,6 +266,9 @@ void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp,
   const SCEV *S = SE->getSCEVAtScope(ICmp->getOperand(IVOperIdx), ICmpLoop);
   const SCEV *X = SE->getSCEVAtScope(ICmp->getOperand(1 - IVOperIdx), ICmpLoop);
 
+  bool IsExitCond = false;
+  if (ICmp == L->getLatchCmpInst())
----------------
Meinersbur wrote:

Any exit can influence BackedgeTakenCount. If it didn't affect a test, it doesn't mean it automatically becomes correct, but that we don't have tests that covers it. A reason would be needed why it is only a problem with the latch. `forgetValue` obviously is not sufficient. To be on the safe side, it would be better to conservatively any exit.

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


More information about the llvm-commits mailing list