[PATCH] D28724: Use getLoopLatch in place of isLoopSimplifyForm

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 13 22:15:18 PST 2017


trentxintong created this revision.
trentxintong added reviewers: hfinkel, sanjoy, atrick, mkuper.
trentxintong added a subscriber: llvm-commits.
Herald added a subscriber: mzolotukhin.

Use getLoopLatch in place of isLoopSimplifyForm. we do not need
to know whether the loop has a preheader nor dedicated exits.


https://reviews.llvm.org/D28724

Files:
  lib/Analysis/LoopInfo.cpp


Index: lib/Analysis/LoopInfo.cpp
===================================================================
--- lib/Analysis/LoopInfo.cpp
+++ lib/Analysis/LoopInfo.cpp
@@ -211,8 +211,8 @@
 
 MDNode *Loop::getLoopID() const {
   MDNode *LoopID = nullptr;
-  if (isLoopSimplifyForm()) {
-    LoopID = getLoopLatch()->getTerminator()->getMetadata(LLVMContext::MD_loop);
+  if (BasicBlock *Latch = getLoopLatch()) {
+    LoopID = Latch->getTerminator()->getMetadata(LLVMContext::MD_loop);
   } else {
     // Go through each predecessor of the loop header and check the
     // terminator for the metadata.
@@ -248,7 +248,7 @@
   assert(LoopID->getNumOperands() > 0 && "Loop ID needs at least one operand");
   assert(LoopID->getOperand(0) == LoopID && "Loop ID should refer to itself");
 
-  if (isLoopSimplifyForm()) {
+  if (BasicBlock *Latch = getLoopLatch()) {
     getLoopLatch()->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28724.84427.patch
Type: text/x-patch
Size: 954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170114/0c95d4bf/attachment.bin>


More information about the llvm-commits mailing list