@@ -187,7 +187,7 @@ namespace {
187
187
const DataLayout &DL,
188
188
OptimizationRemarkEmitter *ORE) :
189
189
SE (SE), DL(DL), ORE(ORE), L(Info.L), M(L->getHeader ()->getModule()),
190
- ExitCount (Info.ExitCount ),
190
+ TripCount (Info.TripCount ),
191
191
CountType(Info.CountType),
192
192
ExitBranch(Info.ExitBranch),
193
193
LoopDecrement(Info.LoopDecrement),
@@ -202,7 +202,7 @@ namespace {
202
202
OptimizationRemarkEmitter *ORE = nullptr ;
203
203
Loop *L = nullptr ;
204
204
Module *M = nullptr ;
205
- const SCEV *ExitCount = nullptr ;
205
+ const SCEV *TripCount = nullptr ;
206
206
Type *CountType = nullptr ;
207
207
BranchInst *ExitBranch = nullptr ;
208
208
Value *LoopDecrement = nullptr ;
@@ -298,7 +298,7 @@ bool HardwareLoops::TryConvertLoop(HardwareLoopInfo &HWLoopInfo) {
298
298
}
299
299
300
300
assert (
301
- (HWLoopInfo.ExitBlock && HWLoopInfo.ExitBranch && HWLoopInfo.ExitCount ) &&
301
+ (HWLoopInfo.ExitBlock && HWLoopInfo.ExitBranch && HWLoopInfo.TripCount ) &&
302
302
" Hardware Loop must have set exit info." );
303
303
304
304
BasicBlock *Preheader = L->getLoopPreheader ();
@@ -383,18 +383,13 @@ Value *HardwareLoop::InitLoopCount() {
383
383
// loop counter and tests that is not zero?
384
384
385
385
SCEVExpander SCEVE (SE, DL, " loopcnt" );
386
- if (!ExitCount->getType ()->isPointerTy () &&
387
- ExitCount->getType () != CountType)
388
- ExitCount = SE.getZeroExtendExpr (ExitCount, CountType);
389
-
390
- ExitCount = SE.getAddExpr (ExitCount, SE.getOne (CountType));
391
386
392
387
// If we're trying to use the 'test and set' form of the intrinsic, we need
393
388
// to replace a conditional branch that is controlling entry to the loop. It
394
389
// is likely (guaranteed?) that the preheader has an unconditional branch to
395
390
// the loop header, so also check if it has a single predecessor.
396
- if (SE.isLoopEntryGuardedByCond (L, ICmpInst::ICMP_NE, ExitCount ,
397
- SE.getZero (ExitCount ->getType ()))) {
391
+ if (SE.isLoopEntryGuardedByCond (L, ICmpInst::ICMP_NE, TripCount ,
392
+ SE.getZero (TripCount ->getType ()))) {
398
393
LLVM_DEBUG (dbgs () << " - Attempting to use test.set counter.\n " );
399
394
UseLoopGuard |= ForceGuardLoopEntry;
400
395
} else
@@ -406,19 +401,19 @@ Value *HardwareLoop::InitLoopCount() {
406
401
BasicBlock *Predecessor = BB->getSinglePredecessor ();
407
402
// If it's not safe to create a while loop then don't force it and create a
408
403
// do-while loop instead
409
- if (!isSafeToExpandAt (ExitCount , Predecessor->getTerminator (), SE))
404
+ if (!isSafeToExpandAt (TripCount , Predecessor->getTerminator (), SE))
410
405
UseLoopGuard = false ;
411
406
else
412
407
BB = Predecessor;
413
408
}
414
409
415
- if (!isSafeToExpandAt (ExitCount , BB->getTerminator (), SE)) {
416
- LLVM_DEBUG (dbgs () << " - Bailing, unsafe to expand ExitCount "
417
- << *ExitCount << " \n " );
410
+ if (!isSafeToExpandAt (TripCount , BB->getTerminator (), SE)) {
411
+ LLVM_DEBUG (dbgs () << " - Bailing, unsafe to expand TripCount "
412
+ << *TripCount << " \n " );
418
413
return nullptr ;
419
414
}
420
415
421
- Value *Count = SCEVE.expandCodeFor (ExitCount , CountType,
416
+ Value *Count = SCEVE.expandCodeFor (TripCount , CountType,
422
417
BB->getTerminator ());
423
418
424
419
// FIXME: We've expanded Count where we hope to insert the counter setting
0 commit comments