@@ -110,7 +110,7 @@ static void ConnectProlog(Loop *L, Value *BECount, unsigned Count,
110
110
}
111
111
}
112
112
113
- // Create a branch around the orignal loop, which is taken if there are no
113
+ // Create a branch around the original loop, which is taken if there are no
114
114
// iterations remaining to be executed after running the prologue.
115
115
Instruction *InsertPt = PrologEnd->getTerminator ();
116
116
IRBuilder<> B (InsertPt);
@@ -281,7 +281,7 @@ bool llvm::UnrollRuntimeLoopProlog(Loop *L, unsigned Count,
281
281
bool AllowExpensiveTripCount, LoopInfo *LI,
282
282
ScalarEvolution *SE, DominatorTree *DT,
283
283
bool PreserveLCSSA) {
284
- // for now, only unroll loops that contain a single exit
284
+ // For now, only unroll loops that contain a single exit.
285
285
if (!L->getExitingBlock ())
286
286
return false ;
287
287
@@ -290,21 +290,21 @@ bool llvm::UnrollRuntimeLoopProlog(Loop *L, unsigned Count,
290
290
if (!L->isLoopSimplifyForm () || !L->getUniqueExitBlock ())
291
291
return false ;
292
292
293
- // Use Scalar Evolution to compute the trip count. This allows more
294
- // loops to be unrolled than relying on induction var simplification
293
+ // Use Scalar Evolution to compute the trip count. This allows more loops to
294
+ // be unrolled than relying on induction var simplification.
295
295
if (!SE)
296
296
return false ;
297
297
298
- // Only unroll loops with a computable trip count and the trip count needs
299
- // to be an int value (allowing a pointer type is a TODO item)
298
+ // Only unroll loops with a computable trip count, and the trip count needs
299
+ // to be an int value (allowing a pointer type is a TODO item).
300
300
const SCEV *BECountSC = SE->getBackedgeTakenCount (L);
301
301
if (isa<SCEVCouldNotCompute>(BECountSC) ||
302
302
!BECountSC->getType ()->isIntegerTy ())
303
303
return false ;
304
304
305
305
unsigned BEWidth = cast<IntegerType>(BECountSC->getType ())->getBitWidth ();
306
306
307
- // Add 1 since the backedge count doesn't include the first loop iteration
307
+ // Add 1 since the backedge count doesn't include the first loop iteration.
308
308
const SCEV *TripCountSC =
309
309
SE->getAddExpr (BECountSC, SE->getConstant (BECountSC->getType (), 1 ));
310
310
if (isa<SCEVCouldNotCompute>(TripCountSC))
@@ -326,15 +326,15 @@ bool llvm::UnrollRuntimeLoopProlog(Loop *L, unsigned Count,
326
326
if (Log2_32 (Count) > BEWidth)
327
327
return false ;
328
328
329
- // If this loop is nested, then the loop unroller changes the code in
330
- // parent loop, so the Scalar Evolution pass needs to be run again
329
+ // If this loop is nested, then the loop unroller changes the code in the
330
+ // parent loop, so the Scalar Evolution pass needs to be run again.
331
331
if (Loop *ParentLoop = L->getParentLoop ())
332
332
SE->forgetLoop (ParentLoop);
333
333
334
334
BasicBlock *PH = L->getLoopPreheader ();
335
335
BasicBlock *Latch = L->getLoopLatch ();
336
- // It helps to splits the original preheader twice, one for the end of the
337
- // prolog code and one for a new loop preheader
336
+ // It helps to split the original preheader twice, one for the end of the
337
+ // prolog code and one for a new loop preheader.
338
338
BasicBlock *PEnd = SplitEdge (PH, Header, DT, LI);
339
339
BasicBlock *NewPH = SplitBlock (PEnd, PEnd->getTerminator (), DT, LI);
340
340
BranchInst *PreHeaderBR = cast<BranchInst>(PH->getTerminator ());
@@ -350,9 +350,9 @@ bool llvm::UnrollRuntimeLoopProlog(Loop *L, unsigned Count,
350
350
Value *ModVal = B.CreateAnd (TripCount, Count - 1 , " xtraiter" );
351
351
352
352
// If ModVal is zero, we know that either
353
- // 1. there are no iteration to be run in the prologue loop
353
+ // 1. There are no iterations to be run in the prologue loop.
354
354
// OR
355
- // 2. the addition computing TripCount overflowed
355
+ // 2. The addition computing TripCount overflowed.
356
356
//
357
357
// If (2) is true, we know that TripCount really is (1 << BEWidth) and so the
358
358
// number of iterations that remain to be run in the original loop is a
@@ -361,16 +361,16 @@ bool llvm::UnrollRuntimeLoopProlog(Loop *L, unsigned Count,
361
361
362
362
Value *BranchVal = B.CreateIsNotNull (ModVal, " lcmp.mod" );
363
363
364
- // Branch to either the extra iterations or the cloned/unrolled loop
365
- // We will fix up the true branch label when adding loop body copies
364
+ // Branch to either the extra iterations or the cloned/unrolled loop.
365
+ // We will fix up the true branch label when adding loop body copies.
366
366
B.CreateCondBr (BranchVal, PEnd, PEnd);
367
367
assert (PreHeaderBR->isUnconditional () &&
368
368
PreHeaderBR->getSuccessor (0 ) == PEnd &&
369
369
" CFG edges in Preheader are not correct" );
370
370
PreHeaderBR->eraseFromParent ();
371
371
Function *F = Header->getParent ();
372
372
// Get an ordered list of blocks in the loop to help with the ordering of the
373
- // cloned blocks in the prolog code
373
+ // cloned blocks in the prolog code.
374
374
LoopBlocksDFS LoopBlocks (L);
375
375
LoopBlocks.perform (LI);
376
376
@@ -390,7 +390,7 @@ bool llvm::UnrollRuntimeLoopProlog(Loop *L, unsigned Count,
390
390
CloneLoopBlocks (L, ModVal, UnrollPrologue, PH, PEnd, NewBlocks, LoopBlocks,
391
391
VMap, LI);
392
392
393
- // Insert the cloned blocks into function just before the original loop
393
+ // Insert the cloned blocks into the function just before the original loop.
394
394
F->getBasicBlockList ().splice (PEnd->getIterator (), F->getBasicBlockList (),
395
395
NewBlocks[0 ]->getIterator (), F->end ());
396
396
0 commit comments