[PATCH] D90115: [LoopDeletion] Remove dead loops with no exit blocks

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 26 16:25:15 PDT 2020


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

LGTM, a few nits to be addressed prior to the merge.



================
Comment at: llvm/include/llvm/Analysis/LoopInfoImpl.h:75
+  getExitBlocks(UniqueExitBlocks);
+  return UniqueExitBlocks.empty();
+}
----------------
-Unique


================
Comment at: llvm/lib/Transforms/Scalar/LoopDeletion.cpp:200
+    LLVM_DEBUG(
+        dbgs() << "Deletion requires single exit block or no exit blocks\n");
     return LoopDeletionResult::Unmodified;
----------------
Nit: aka, at most one exit block ;)


================
Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:685
       DeadDebugInst.push_back(DVI);
     }
 
----------------
Assuming the only use of the DeadDebugInst vector is the code blow that we don't execute (no point to "move" the stuff to), this entire loop is useless for the no-exit case.

Line 668 is trivially true for the no-exit case and 677-684 not needed as described above.

Thus, move the if(ExitBlock) to 648.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90115



More information about the llvm-commits mailing list