[PATCH] D105688: [LoopDeletion] Handle switch in proving that loop exits on first iteration

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 9 03:10:18 PDT 2021


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM as well.



================
Comment at: llvm/lib/Transforms/Scalar/LoopDeletion.cpp:321
     auto *Term = BB->getTerminator();
-    // TODO: Handle switch.
-    if (!match(Term, m_Br(m_ICmp(Pred, m_Value(LHS), m_Value(RHS)),
-                          m_BasicBlock(IfTrue), m_BasicBlock(IfFalse)))) {
-      MarkAllSuccessorsLive(BB);
-      continue;
-    }
-
-    if (!LHS->getType()->isIntegerTy()) {
-      MarkAllSuccessorsLive(BB);
-      continue;
-    }
+    if (match(Term, m_Br(m_ICmp(Pred, m_Value(LHS), m_Value(RHS)),
+                         m_BasicBlock(IfTrue), m_BasicBlock(IfFalse)))) {
----------------
Just as a side-note: I think it would be nice to move the SimplifyICmpInst handling into getValueOnFirstIteration(), and then this could just directly work on the br argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105688



More information about the llvm-commits mailing list