Owen Anderson | 2306a1e | 2008-04-29 20:06:54 +0000 | [diff] [blame] | 1 | //===- LoopDeletion.cpp - Dead Loop Deletion Pass ---------------===// |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Gordon Henriksen | 829046b | 2008-05-08 17:46:35 +0000 | [diff] [blame] | 10 | // This file implements the Dead Loop Deletion Pass. This pass is responsible |
| 11 | // for eliminating loops with non-infinite computable trip counts that have no |
| 12 | // side effects or volatile instructions, and do not contribute to the |
| 13 | // computation of the function's return value. |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 17 | #include "llvm/Transforms/Scalar/LoopDeletion.h" |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallVector.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/Statistic.h" |
James Molloy | efbba72 | 2015-09-10 10:22:12 +0000 | [diff] [blame] | 20 | #include "llvm/Analysis/GlobalsModRef.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 21 | #include "llvm/Analysis/LoopPass.h" |
Chandler Carruth | 5ad5f15 | 2014-01-13 09:26:24 +0000 | [diff] [blame] | 22 | #include "llvm/IR/Dominators.h" |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 23 | #include "llvm/IR/PatternMatch.h" |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 24 | #include "llvm/Transforms/Scalar.h" |
Chandler Carruth | 3bab7e1 | 2017-01-11 09:43:56 +0000 | [diff] [blame] | 25 | #include "llvm/Transforms/Scalar/LoopPassManager.h" |
Chandler Carruth | 31088a9 | 2016-02-19 10:45:18 +0000 | [diff] [blame] | 26 | #include "llvm/Transforms/Utils/LoopUtils.h" |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 27 | using namespace llvm; |
| 28 | |
Chandler Carruth | 964daaa | 2014-04-22 02:55:47 +0000 | [diff] [blame] | 29 | #define DEBUG_TYPE "loop-delete" |
| 30 | |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 31 | STATISTIC(NumDeleted, "Number of loops deleted"); |
| 32 | |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 33 | enum class LoopDeletionResult { |
| 34 | Unmodified, |
| 35 | Modified, |
| 36 | Deleted, |
| 37 | }; |
| 38 | |
Chandler Carruth | 26169f00 | 2017-01-17 22:07:26 +0000 | [diff] [blame] | 39 | /// Determines if a loop is dead. |
| 40 | /// |
| 41 | /// This assumes that we've already checked for unique exit and exiting blocks, |
| 42 | /// and that the code is in LCSSA form. |
| 43 | static bool isLoopDead(Loop *L, ScalarEvolution &SE, |
| 44 | SmallVectorImpl<BasicBlock *> &ExitingBlocks, |
| 45 | BasicBlock *ExitBlock, bool &Changed, |
| 46 | BasicBlock *Preheader) { |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 47 | // Make sure that all PHI entries coming from the loop are loop invariant. |
Owen Anderson | e674600 | 2008-04-29 20:59:33 +0000 | [diff] [blame] | 48 | // Because the code is in LCSSA form, any values used outside of the loop |
| 49 | // must pass through a PHI in the exit block, meaning that this check is |
| 50 | // sufficient to guarantee that no loop-variant values are used outside |
| 51 | // of the loop. |
Chandler Carruth | 04a7387 | 2017-01-17 21:51:39 +0000 | [diff] [blame] | 52 | BasicBlock::iterator BI = ExitBlock->begin(); |
Sanjoy Das | 905fc27 | 2016-05-03 17:50:02 +0000 | [diff] [blame] | 53 | bool AllEntriesInvariant = true; |
| 54 | bool AllOutgoingValuesSame = true; |
Jakub Staszak | bc421ef | 2013-03-18 23:31:30 +0000 | [diff] [blame] | 55 | while (PHINode *P = dyn_cast<PHINode>(BI)) { |
Chandler Carruth | 04a7387 | 2017-01-17 21:51:39 +0000 | [diff] [blame] | 56 | Value *incoming = P->getIncomingValueForBlock(ExitingBlocks[0]); |
Cameron Zwarich | 8263085 | 2011-02-22 22:25:39 +0000 | [diff] [blame] | 57 | |
| 58 | // Make sure all exiting blocks produce the same incoming value for the exit |
| 59 | // block. If there are different incoming values for different exiting |
| 60 | // blocks, then it is impossible to statically determine which value should |
| 61 | // be used. |
Sanjoy Das | 7e7a5a0 | 2016-05-03 17:50:06 +0000 | [diff] [blame] | 62 | AllOutgoingValuesSame = |
Chandler Carruth | 04a7387 | 2017-01-17 21:51:39 +0000 | [diff] [blame] | 63 | all_of(makeArrayRef(ExitingBlocks).slice(1), [&](BasicBlock *BB) { |
Sanjoy Das | 7e7a5a0 | 2016-05-03 17:50:06 +0000 | [diff] [blame] | 64 | return incoming == P->getIncomingValueForBlock(BB); |
| 65 | }); |
Nadav Rotem | 465834c | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 66 | |
Sanjoy Das | 905fc27 | 2016-05-03 17:50:02 +0000 | [diff] [blame] | 67 | if (!AllOutgoingValuesSame) |
| 68 | break; |
| 69 | |
Jakub Staszak | bc421ef | 2013-03-18 23:31:30 +0000 | [diff] [blame] | 70 | if (Instruction *I = dyn_cast<Instruction>(incoming)) |
Sanjoy Das | 905fc27 | 2016-05-03 17:50:02 +0000 | [diff] [blame] | 71 | if (!L->makeLoopInvariant(I, Changed, Preheader->getTerminator())) { |
| 72 | AllEntriesInvariant = false; |
| 73 | break; |
| 74 | } |
Cameron Zwarich | 8263085 | 2011-02-22 22:25:39 +0000 | [diff] [blame] | 75 | |
Dan Gohman | d2d1ae1 | 2010-06-22 15:08:57 +0000 | [diff] [blame] | 76 | ++BI; |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 77 | } |
Nadav Rotem | 465834c | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 78 | |
Sanjoy Das | 905fc27 | 2016-05-03 17:50:02 +0000 | [diff] [blame] | 79 | if (Changed) |
| 80 | SE.forgetLoopDispositions(L); |
| 81 | |
| 82 | if (!AllEntriesInvariant || !AllOutgoingValuesSame) |
| 83 | return false; |
| 84 | |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 85 | // Make sure that no instructions in the block have potential side-effects. |
Owen Anderson | e674600 | 2008-04-29 20:59:33 +0000 | [diff] [blame] | 86 | // This includes instructions that could write to memory, and loads that are |
Xin Tong | df4dff3 | 2017-02-23 23:47:10 +0000 | [diff] [blame] | 87 | // marked volatile. |
Davide Italiano | 49a0aac | 2017-02-26 07:08:20 +0000 | [diff] [blame] | 88 | for (auto &I : L->blocks()) |
| 89 | if (any_of(*I, [](Instruction &I) { return I.mayHaveSideEffects(); })) |
| 90 | return false; |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 91 | return true; |
| 92 | } |
| 93 | |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 94 | /// This function returns true if there is no viable path from the |
| 95 | /// entry block to the header of \p L. Right now, it only does |
| 96 | /// a local search to save compile time. |
| 97 | static bool isLoopNeverExecuted(Loop *L) { |
| 98 | using namespace PatternMatch; |
| 99 | |
| 100 | auto *Preheader = L->getLoopPreheader(); |
| 101 | // TODO: We can relax this constraint, since we just need a loop |
| 102 | // predecessor. |
| 103 | assert(Preheader && "Needs preheader!"); |
| 104 | |
| 105 | if (Preheader == &Preheader->getParent()->getEntryBlock()) |
| 106 | return false; |
| 107 | // All predecessors of the preheader should have a constant conditional |
| 108 | // branch, with the loop's preheader as not-taken. |
| 109 | for (auto *Pred: predecessors(Preheader)) { |
| 110 | BasicBlock *Taken, *NotTaken; |
| 111 | ConstantInt *Cond; |
| 112 | if (!match(Pred->getTerminator(), |
| 113 | m_Br(m_ConstantInt(Cond), Taken, NotTaken))) |
| 114 | return false; |
| 115 | if (!Cond->getZExtValue()) |
| 116 | std::swap(Taken, NotTaken); |
| 117 | if (Taken == Preheader) |
| 118 | return false; |
| 119 | } |
| 120 | assert(!pred_empty(Preheader) && |
| 121 | "Preheader should have predecessors at this point!"); |
| 122 | // All the predecessors have the loop preheader as not-taken target. |
| 123 | return true; |
| 124 | } |
| 125 | |
Chandler Carruth | 26169f00 | 2017-01-17 22:07:26 +0000 | [diff] [blame] | 126 | /// Remove a loop if it is dead. |
| 127 | /// |
| 128 | /// A loop is considered dead if it does not impact the observable behavior of |
| 129 | /// the program other than finite running time. This never removes a loop that |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 130 | /// might be infinite (unless it is never executed), as doing so could change |
| 131 | /// the halting/non-halting nature of a program. |
Chandler Carruth | 26169f00 | 2017-01-17 22:07:26 +0000 | [diff] [blame] | 132 | /// |
| 133 | /// This entire process relies pretty heavily on LoopSimplify form and LCSSA in |
| 134 | /// order to make various safety checks work. |
| 135 | /// |
Chandler Carruth | 027340f | 2017-02-11 00:09:30 +0000 | [diff] [blame] | 136 | /// \returns true if any changes were made. This may mutate the loop even if it |
| 137 | /// is unable to delete it due to hoisting trivially loop invariant |
| 138 | /// instructions out of the loop. |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 139 | static LoopDeletionResult deleteLoopIfDead(Loop *L, DominatorTree &DT, |
| 140 | ScalarEvolution &SE, LoopInfo &LI) { |
Sanjoy Das | 979a11d | 2016-02-21 17:11:59 +0000 | [diff] [blame] | 141 | assert(L->isLCSSAForm(DT) && "Expected LCSSA!"); |
| 142 | |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 143 | // We can only remove the loop if there is a preheader that we can branch from |
| 144 | // after removing it. Also, if LoopSimplify form is not available, stay out |
| 145 | // of trouble. |
Chandler Carruth | aa885c9 | 2017-01-17 22:19:56 +0000 | [diff] [blame] | 146 | BasicBlock *Preheader = L->getLoopPreheader(); |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 147 | if (!Preheader || !L->hasDedicatedExits()) { |
| 148 | DEBUG(dbgs() |
| 149 | << "Deletion requires Loop with preheader and dedicated exits.\n"); |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 150 | return LoopDeletionResult::Unmodified; |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 151 | } |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 152 | // We can't remove loops that contain subloops. If the subloops were dead, |
| 153 | // they would already have been removed in earlier executions of this pass. |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 154 | if (L->begin() != L->end()) { |
| 155 | DEBUG(dbgs() << "Loop contains subloops.\n"); |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 156 | return LoopDeletionResult::Unmodified; |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 157 | } |
Nadav Rotem | 465834c | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 158 | |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 159 | |
| 160 | BasicBlock *ExitBlock = L->getUniqueExitBlock(); |
| 161 | |
| 162 | if (ExitBlock && isLoopNeverExecuted(L)) { |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 163 | DEBUG(dbgs() << "Loop is proven to never execute, delete it!"); |
Anna Thomas | e7cb633 | 2017-06-25 21:13:58 +0000 | [diff] [blame] | 164 | // Set incoming value to undef for phi nodes in the exit block. |
| 165 | BasicBlock::iterator BI = ExitBlock->begin(); |
| 166 | while (PHINode *P = dyn_cast<PHINode>(BI)) { |
| 167 | for (unsigned i = 0; i < P->getNumIncomingValues(); i++) |
| 168 | P->setIncomingValue(i, UndefValue::get(P->getType())); |
| 169 | BI++; |
| 170 | } |
Marcello Maggioni | df3e71e | 2017-10-04 20:42:46 +0000 | [diff] [blame] | 171 | deleteDeadLoop(L, &DT, &SE, &LI); |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 172 | ++NumDeleted; |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 173 | return LoopDeletionResult::Deleted; |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | // The remaining checks below are for a loop being dead because all statements |
| 177 | // in the loop are invariant. |
Chandler Carruth | 04a7387 | 2017-01-17 21:51:39 +0000 | [diff] [blame] | 178 | SmallVector<BasicBlock *, 4> ExitingBlocks; |
| 179 | L->getExitingBlocks(ExitingBlocks); |
Nadav Rotem | 465834c | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 180 | |
Owen Anderson | ad5f211 | 2008-05-16 04:32:45 +0000 | [diff] [blame] | 181 | // We require that the loop only have a single exit block. Otherwise, we'd |
| 182 | // be in the situation of needing to be able to solve statically which exit |
| 183 | // block will be branched to, or trying to preserve the branching logic in |
| 184 | // a loop invariant manner. |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 185 | if (!ExitBlock) { |
| 186 | DEBUG(dbgs() << "Deletion requires single exit block\n"); |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 187 | return LoopDeletionResult::Unmodified; |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 188 | } |
Owen Anderson | 94ad702 | 2008-04-29 00:38:34 +0000 | [diff] [blame] | 189 | // Finally, we have to check that the loop really is dead. |
Chandler Carruth | 027340f | 2017-02-11 00:09:30 +0000 | [diff] [blame] | 190 | bool Changed = false; |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 191 | if (!isLoopDead(L, SE, ExitingBlocks, ExitBlock, Changed, Preheader)) { |
| 192 | DEBUG(dbgs() << "Loop is not invariant, cannot delete.\n"); |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 193 | return Changed ? LoopDeletionResult::Modified |
| 194 | : LoopDeletionResult::Unmodified; |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 195 | } |
Nadav Rotem | 465834c | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 196 | |
Owen Anderson | ad5f211 | 2008-05-16 04:32:45 +0000 | [diff] [blame] | 197 | // Don't remove loops for which we can't solve the trip count. |
| 198 | // They could be infinite, in which case we'd be changing program behavior. |
Dan Gohman | 41d00ac | 2009-10-23 17:10:01 +0000 | [diff] [blame] | 199 | const SCEV *S = SE.getMaxBackedgeTakenCount(L); |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 200 | if (isa<SCEVCouldNotCompute>(S)) { |
| 201 | DEBUG(dbgs() << "Could not compute SCEV MaxBackedgeTakenCount.\n"); |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 202 | return Changed ? LoopDeletionResult::Modified |
| 203 | : LoopDeletionResult::Unmodified; |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 204 | } |
Nadav Rotem | 465834c | 2012-07-24 10:51:42 +0000 | [diff] [blame] | 205 | |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 206 | DEBUG(dbgs() << "Loop is invariant, delete it!"); |
Marcello Maggioni | df3e71e | 2017-10-04 20:42:46 +0000 | [diff] [blame] | 207 | deleteDeadLoop(L, &DT, &SE, &LI); |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 208 | ++NumDeleted; |
| 209 | |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 210 | return LoopDeletionResult::Deleted; |
Anna Thomas | 53c8d95 | 2017-05-03 11:47:11 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Chandler Carruth | 410eaeb | 2017-01-11 06:23:21 +0000 | [diff] [blame] | 213 | PreservedAnalyses LoopDeletionPass::run(Loop &L, LoopAnalysisManager &AM, |
| 214 | LoopStandardAnalysisResults &AR, |
Chandler Carruth | d50c5fb | 2017-01-18 02:41:26 +0000 | [diff] [blame] | 215 | LPMUpdater &Updater) { |
Anna Thomas | 90f69ab | 2017-07-04 14:05:19 +0000 | [diff] [blame] | 216 | |
| 217 | DEBUG(dbgs() << "Analyzing Loop for deletion: "); |
| 218 | DEBUG(L.dump()); |
Sanjoy Das | def1729 | 2017-09-28 02:45:42 +0000 | [diff] [blame] | 219 | std::string LoopName = L.getName(); |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 220 | auto Result = deleteLoopIfDead(&L, AR.DT, AR.SE, AR.LI); |
| 221 | if (Result == LoopDeletionResult::Unmodified) |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 222 | return PreservedAnalyses::all(); |
| 223 | |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 224 | if (Result == LoopDeletionResult::Deleted) |
Sanjoy Das | def1729 | 2017-09-28 02:45:42 +0000 | [diff] [blame] | 225 | Updater.markLoopAsDeleted(L, LoopName); |
Sanjoy Das | 8e8c1bc | 2017-09-27 21:45:21 +0000 | [diff] [blame] | 226 | |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 227 | return getLoopPassPreservedAnalyses(); |
| 228 | } |
| 229 | |
| 230 | namespace { |
| 231 | class LoopDeletionLegacyPass : public LoopPass { |
| 232 | public: |
| 233 | static char ID; // Pass ID, replacement for typeid |
| 234 | LoopDeletionLegacyPass() : LoopPass(ID) { |
| 235 | initializeLoopDeletionLegacyPassPass(*PassRegistry::getPassRegistry()); |
| 236 | } |
| 237 | |
| 238 | // Possibly eliminate loop L if it is dead. |
| 239 | bool runOnLoop(Loop *L, LPPassManager &) override; |
| 240 | |
| 241 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
| 242 | getLoopAnalysisUsage(AU); |
| 243 | } |
| 244 | }; |
| 245 | } |
| 246 | |
| 247 | char LoopDeletionLegacyPass::ID = 0; |
| 248 | INITIALIZE_PASS_BEGIN(LoopDeletionLegacyPass, "loop-deletion", |
| 249 | "Delete dead loops", false, false) |
| 250 | INITIALIZE_PASS_DEPENDENCY(LoopPass) |
| 251 | INITIALIZE_PASS_END(LoopDeletionLegacyPass, "loop-deletion", |
| 252 | "Delete dead loops", false, false) |
| 253 | |
| 254 | Pass *llvm::createLoopDeletionPass() { return new LoopDeletionLegacyPass(); } |
| 255 | |
Sanjoy Das | def1729 | 2017-09-28 02:45:42 +0000 | [diff] [blame] | 256 | bool LoopDeletionLegacyPass::runOnLoop(Loop *L, LPPassManager &LPM) { |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 257 | if (skipLoop(L)) |
| 258 | return false; |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 259 | DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
| 260 | ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE(); |
Chandler Carruth | 04a7387 | 2017-01-17 21:51:39 +0000 | [diff] [blame] | 261 | LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 262 | |
Anna Thomas | ada4ddc | 2017-07-04 17:00:03 +0000 | [diff] [blame] | 263 | DEBUG(dbgs() << "Analyzing Loop for deletion: "); |
| 264 | DEBUG(L->dump()); |
Sanjoy Das | def1729 | 2017-09-28 02:45:42 +0000 | [diff] [blame] | 265 | |
| 266 | LoopDeletionResult Result = deleteLoopIfDead(L, DT, SE, LI); |
| 267 | |
| 268 | if (Result == LoopDeletionResult::Deleted) |
| 269 | LPM.markLoopAsDeleted(*L); |
| 270 | |
| 271 | return Result != LoopDeletionResult::Unmodified; |
Jun Bum Lim | c837af3 | 2016-07-14 18:28:29 +0000 | [diff] [blame] | 272 | } |