Home | History | Annotate | Download | only in Scalar

Lines Matching refs:Loop

1 //===-- LoopUnroll.cpp - Loop unroller pass -------------------------------===//
10 // This pass implements a simple loop unroller. It works best when loops have
33 #define DEBUG_TYPE "loop-unroll"
37 cl::desc("The cut-off point for automatic loop unrolling"));
47 "-unroll-threshold loop size is reached."));
78 /// that the loop unroll should be performed regardless of how much
99 bool runOnLoop(Loop *L, LPPassManager &LPM) override;
101 /// This transformation requires natural loop information & requires that
102 /// loop preheaders be inserted into the CFG...
114 // FIXME: Loop unroll requires LCSSA. And LCSSA requires dom info.
115 // If loop unroll does not preserve dom info then LCSSA pass on next
116 // loop will receive invalid dom info.
117 // For now, recreate dom info, if loop is unrolled.
123 void getUnrollingPreferences(Loop *L, const TargetTransformInfo &TTI,
141 selectUnrollCount(const Loop *L, unsigned TripCount, bool HasEnablePragma,
151 void selectThresholds(const Loop *L, bool HasPragma,
169 // If the loop has an unrolling pragma, we want to be more
184 INITIALIZE_PASS_BEGIN(LoopUnroll, "loop-unroll", "Unroll loops", false, false)
190 INITIALIZE_PASS_END(LoopUnroll, "loop-unroll", "Unroll loops", false, false)
201 /// ApproximateLoopSize - Approximate the size of the loop.
202 static unsigned ApproximateLoopSize(const Loop *L, unsigned &NumCalls,
206 for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
223 // example, "llvm.loop.unroll.count"). If no such named metadata node
225 static const ConstantInt *GetUnrollMetadataValue(const Loop *L,
230 // First operand should refer to the loop id itself.
232 assert(LoopID->getOperand(0) == LoopID && "invalid loop id");
250 // Returns true if the loop has an unroll(enable) pragma.
251 static bool HasUnrollEnablePragma(const Loop *L) {
253 GetUnrollMetadataValue(L, "llvm.loop.unroll.enable");
257 // Returns true if the loop has an unroll(disable) pragma.
258 static bool HasUnrollDisablePragma(const Loop *L) {
260 GetUnrollMetadataValue(L, "llvm.loop.unroll.enable");
264 // If loop has an unroll_count pragma return the (necessarily
266 static unsigned UnrollCountPragmaValue(const Loop *L) {
268 GetUnrollMetadataValue(L, "llvm.loop.unroll.count");
278 const Loop *L, unsigned TripCount, bool HasEnablePragma,
294 // indicates to unroll loop fully.
319 bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
328 DEBUG(dbgs() << "Loop Unroll: F[" << Header->getParent()->getName()
329 << "] Loop %" << Header->getName() << "\n");
345 // via the loop latch on any iteration prior to TripCount. The loop may exit
363 DEBUG(dbgs() << " Loop Size = " << LoopSize << "\n");
366 DEBUG(dbgs() << " Not unrolling loop which contains non-duplicatable"
371 DEBUG(dbgs() << " Not unrolling loop with inlinable calls.\n");
415 DEBUG(dbgs() << " will not try to unroll loop with runtime trip count "
431 // Emit optimization remarks if we are unable to unroll the loop
440 "Unable to fully unroll loop as directed by unroll(enable) pragma "
445 "Unable to fully unroll loop as directed by unroll(enable) pragma "
446 "because loop has a runtime trip count.");
451 "Unable to unroll loop the number of times directed by "
458 // of 1 makes sense because loop control can be eliminated.
462 // Unroll the loop.