@@ -530,6 +530,9 @@ class InnerLoopVectorizer {
530
530
// / Returns (and creates if needed) the trip count of the widened loop.
531
531
Value *getOrCreateVectorTripCount (BasicBlock *InsertBlock);
532
532
533
+ // Create a check to see if the vector loop should be executed
534
+ Value *createIterationCountCheck (ElementCount VF, unsigned UF) const ;
535
+
533
536
// / Emit a bypass check to see if the vector trip count is zero, including if
534
537
// / it overflows.
535
538
void emitIterationCountCheck (BasicBlock *Bypass);
@@ -2370,13 +2373,8 @@ void InnerLoopVectorizer::introduceCheckBlockInVPlan(BasicBlock *CheckIRBB) {
2370
2373
}
2371
2374
}
2372
2375
2373
- void InnerLoopVectorizer::emitIterationCountCheck (BasicBlock *Bypass) {
2374
- Value *Count = getTripCount ();
2375
- // Reuse existing vector loop preheader for TC checks.
2376
- // Note that new preheader block is generated for vector loop.
2377
- BasicBlock *const TCCheckBlock = LoopVectorPreHeader;
2378
- IRBuilder<> Builder (TCCheckBlock->getTerminator ());
2379
-
2376
+ Value *InnerLoopVectorizer::createIterationCountCheck (ElementCount VF,
2377
+ unsigned UF) const {
2380
2378
// Generate code to check if the loop's trip count is less than VF * UF, or
2381
2379
// equal to it in case a scalar epilogue is required; this implies that the
2382
2380
// vector trip count is zero. This check also covers the case where adding one
@@ -2385,7 +2383,13 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
2385
2383
auto P = Cost->requiresScalarEpilogue (VF.isVector ()) ? ICmpInst::ICMP_ULE
2386
2384
: ICmpInst::ICMP_ULT;
2387
2385
2386
+ // Reuse existing vector loop preheader for TC checks.
2387
+ // Note that new preheader block is generated for vector loop.
2388
+ BasicBlock *const TCCheckBlock = LoopVectorPreHeader;
2389
+ IRBuilder<> Builder (TCCheckBlock->getTerminator ());
2390
+
2388
2391
// If tail is to be folded, vector loop takes care of all iterations.
2392
+ Value *Count = getTripCount ();
2389
2393
Type *CountTy = Count->getType ();
2390
2394
Value *CheckMinIters = Builder.getFalse ();
2391
2395
auto CreateStep = [&]() -> Value * {
@@ -2434,7 +2438,12 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
2434
2438
// Don't execute the vector loop if (UMax - n) < (VF * UF).
2435
2439
CheckMinIters = Builder.CreateICmp (ICmpInst::ICMP_ULT, LHS, CreateStep ());
2436
2440
}
2441
+ return CheckMinIters;
2442
+ }
2437
2443
2444
+ void InnerLoopVectorizer::emitIterationCountCheck (BasicBlock *Bypass) {
2445
+ BasicBlock *const TCCheckBlock = LoopVectorPreHeader;
2446
+ Value *CheckMinIters = createIterationCountCheck (VF, UF);
2438
2447
// Create new preheader for vector loop.
2439
2448
LoopVectorPreHeader = SplitBlock (TCCheckBlock, TCCheckBlock->getTerminator (),
2440
2449
static_cast <DominatorTree *>(nullptr ), LI,
0 commit comments