[llvm] [ConstraintElim] Generalize IV logic to chain of exiting blocks. (PR #108031)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 09:27:19 PDT 2024


================
@@ -1048,6 +1051,28 @@ void State::addInfoForInductions(BasicBlock &BB) {
   }
 }
 
+void State::addInfoForInductions(BasicBlock &BB) {
+  auto *L = LI.getLoopFor(&BB);
+  if (!L)
+    return;
+  if (L->getHeader() != &BB)
+    return;
+
+  BasicBlock *Curr = &BB;
+  while (L->isLoopExiting(Curr)) {
+    // Don't try to add condition from latch to loop header.
+    if (L->isLoopLatch(Curr))
+      break;
+    auto *Term = dyn_cast<BranchInst>(Curr->getTerminator());
+    if (!Term)
+      break;
+    if (isa<ICmpInst>(Term->getCondition()))
+      addInfoForInduction(cast<ICmpInst>(Term->getCondition()), L);
----------------
fhahn wrote:

Done, thanks!

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


More information about the llvm-commits mailing list