1
- // ===-------- LoopIdiomVectorize.cpp - Loop idiom recognition -- -----------===//
1
+ // ===-------- LoopIdiomVectorize.cpp - Loop idiom vectorization -----------===//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
40
40
// ===----------------------------------------------------------------------===//
41
41
42
42
#include " llvm/Transforms/Vectorize/LoopIdiomVectorize.h"
43
- #include " llvm/ADT/ScopeExit.h"
44
43
#include " llvm/Analysis/DomTreeUpdater.h"
45
44
#include " llvm/Analysis/LoopPass.h"
46
45
#include " llvm/Analysis/TargetTransformInfo.h"
@@ -58,33 +57,27 @@ using namespace PatternMatch;
58
57
59
58
static cl::opt<bool > DisableAll (" disable-loop-idiom-vectorize-all" , cl::Hidden,
60
59
cl::init (false ),
61
- cl::desc(" Disable Loop Idiom Transform Pass." ));
60
+ cl::desc(" Disable Loop Idiom Vectorize Pass." ));
62
61
63
62
static cl::opt<bool >
64
63
DisableByteCmp (" disable-loop-idiom-vectorize-bytecmp" , cl::Hidden,
65
64
cl::init (false ),
66
- cl::desc(" Proceed with Loop Idiom Transform Pass, but do "
65
+ cl::desc(" Proceed with Loop Idiom Vectorize Pass, but do "
67
66
" not convert byte-compare loop(s)." ));
68
67
69
68
static cl::opt<bool >
70
- VerifyLoops (" verify- loop-idiom-vectorize" , cl::Hidden, cl::init(false ),
71
- cl::desc(" Verify loops generated Loop Idiom Transform Pass." ));
69
+ VerifyLoops (" loop-idiom-vectorize-verify " , cl::Hidden, cl::init(false ),
70
+ cl::desc(" Verify loops generated Loop Idiom Vectorize Pass." ));
72
71
73
72
namespace {
73
+
74
74
class LoopIdiomVectorize {
75
75
Loop *CurLoop = nullptr ;
76
76
DominatorTree *DT;
77
77
LoopInfo *LI;
78
78
const TargetTransformInfo *TTI;
79
79
const DataLayout *DL;
80
80
81
- // Blocks that will be used for inserting vectorized code.
82
- BasicBlock *EndBlock = nullptr ;
83
- BasicBlock *VectorLoopPreheaderBlock = nullptr ;
84
- BasicBlock *VectorLoopStartBlock = nullptr ;
85
- BasicBlock *VectorLoopMismatchBlock = nullptr ;
86
- BasicBlock *VectorLoopIncBlock = nullptr ;
87
-
88
81
public:
89
82
explicit LoopIdiomVectorize (DominatorTree *DT, LoopInfo *LI,
90
83
const TargetTransformInfo *TTI,
@@ -102,15 +95,9 @@ class LoopIdiomVectorize {
102
95
SmallVectorImpl<BasicBlock *> &ExitBlocks);
103
96
104
97
bool recognizeByteCompare ();
105
-
106
98
Value *expandFindMismatch (IRBuilder<> &Builder, DomTreeUpdater &DTU,
107
99
GetElementPtrInst *GEPA, GetElementPtrInst *GEPB,
108
100
Instruction *Index, Value *Start, Value *MaxLen);
109
-
110
- Value *createMaskedFindMismatch (IRBuilder<> &Builder, GetElementPtrInst *GEPA,
111
- GetElementPtrInst *GEPB, Value *ExtStart,
112
- Value *ExtEnd);
113
-
114
101
void transformByteCompare (GetElementPtrInst *GEPA, GetElementPtrInst *GEPB,
115
102
PHINode *IndPhi, Value *MaxLen, Instruction *Index,
116
103
Value *Start, bool IncIdx, BasicBlock *FoundBB,
@@ -344,106 +331,6 @@ bool LoopIdiomVectorize::recognizeByteCompare() {
344
331
return true ;
345
332
}
346
333
347
- Value *LoopIdiomVectorize::createMaskedFindMismatch (IRBuilder<> &Builder,
348
- GetElementPtrInst *GEPA,
349
- GetElementPtrInst *GEPB,
350
- Value *ExtStart,
351
- Value *ExtEnd) {
352
- Type *I64Type = Builder.getInt64Ty ();
353
- Type *ResType = Builder.getInt32Ty ();
354
- Type *LoadType = Builder.getInt8Ty ();
355
- Value *PtrA = GEPA->getPointerOperand ();
356
- Value *PtrB = GEPB->getPointerOperand ();
357
-
358
- // At this point we know two things must be true:
359
- // 1. Start <= End
360
- // 2. ExtMaxLen <= MinPageSize due to the page checks.
361
- // Therefore, we know that we can use a 64-bit induction variable that
362
- // starts from 0 -> ExtMaxLen and it will not overflow.
363
- ScalableVectorType *PredVTy =
364
- ScalableVectorType::get (Builder.getInt1Ty (), 16 );
365
-
366
- Value *InitialPred = Builder.CreateIntrinsic (
367
- Intrinsic::get_active_lane_mask, {PredVTy, I64Type}, {ExtStart, ExtEnd});
368
-
369
- Value *VecLen = Builder.CreateIntrinsic (Intrinsic::vscale, {I64Type}, {});
370
- VecLen = Builder.CreateMul (VecLen, ConstantInt::get (I64Type, 16 ), " " ,
371
- /* HasNUW=*/ true , /* HasNSW=*/ true );
372
-
373
- Value *PFalse = Builder.CreateVectorSplat (PredVTy->getElementCount (),
374
- Builder.getInt1 (false ));
375
-
376
- BranchInst *JumpToVectorLoop = BranchInst::Create (VectorLoopStartBlock);
377
- Builder.Insert (JumpToVectorLoop);
378
-
379
- // Set up the first vector loop block by creating the PHIs, doing the vector
380
- // loads and comparing the vectors.
381
- Builder.SetInsertPoint (VectorLoopStartBlock);
382
- PHINode *LoopPred = Builder.CreatePHI (PredVTy, 2 , " mismatch_vec_loop_pred" );
383
- LoopPred->addIncoming (InitialPred, VectorLoopPreheaderBlock);
384
- PHINode *VectorIndexPhi = Builder.CreatePHI (I64Type, 2 , " mismatch_vec_index" );
385
- VectorIndexPhi->addIncoming (ExtStart, VectorLoopPreheaderBlock);
386
- Type *VectorLoadType = ScalableVectorType::get (Builder.getInt8Ty (), 16 );
387
- Value *Passthru = ConstantInt::getNullValue (VectorLoadType);
388
-
389
- Value *VectorLhsGep =
390
- Builder.CreateGEP (LoadType, PtrA, VectorIndexPhi, " " , GEPA->isInBounds ());
391
- Value *VectorLhsLoad = Builder.CreateMaskedLoad (VectorLoadType, VectorLhsGep,
392
- Align (1 ), LoopPred, Passthru);
393
-
394
- Value *VectorRhsGep =
395
- Builder.CreateGEP (LoadType, PtrB, VectorIndexPhi, " " , GEPB->isInBounds ());
396
- Value *VectorRhsLoad = Builder.CreateMaskedLoad (VectorLoadType, VectorRhsGep,
397
- Align (1 ), LoopPred, Passthru);
398
-
399
- Value *VectorMatchCmp = Builder.CreateICmpNE (VectorLhsLoad, VectorRhsLoad);
400
- VectorMatchCmp = Builder.CreateSelect (LoopPred, VectorMatchCmp, PFalse);
401
- Value *VectorMatchHasActiveLanes = Builder.CreateOrReduce (VectorMatchCmp);
402
- BranchInst *VectorEarlyExit = BranchInst::Create (
403
- VectorLoopMismatchBlock, VectorLoopIncBlock, VectorMatchHasActiveLanes);
404
- Builder.Insert (VectorEarlyExit);
405
-
406
- // Increment the index counter and calculate the predicate for the next
407
- // iteration of the loop. We branch back to the start of the loop if there
408
- // is at least one active lane.
409
- Builder.SetInsertPoint (VectorLoopIncBlock);
410
- Value *NewVectorIndexPhi =
411
- Builder.CreateAdd (VectorIndexPhi, VecLen, " " ,
412
- /* HasNUW=*/ true , /* HasNSW=*/ true );
413
- VectorIndexPhi->addIncoming (NewVectorIndexPhi, VectorLoopIncBlock);
414
- Value *NewPred =
415
- Builder.CreateIntrinsic (Intrinsic::get_active_lane_mask,
416
- {PredVTy, I64Type}, {NewVectorIndexPhi, ExtEnd});
417
- LoopPred->addIncoming (NewPred, VectorLoopIncBlock);
418
-
419
- Value *PredHasActiveLanes =
420
- Builder.CreateExtractElement (NewPred, uint64_t (0 ));
421
- BranchInst *VectorLoopBranchBack =
422
- BranchInst::Create (VectorLoopStartBlock, EndBlock, PredHasActiveLanes);
423
- Builder.Insert (VectorLoopBranchBack);
424
-
425
- // If we found a mismatch then we need to calculate which lane in the vector
426
- // had a mismatch and add that on to the current loop index.
427
- Builder.SetInsertPoint (VectorLoopMismatchBlock);
428
- PHINode *FoundPred = Builder.CreatePHI (PredVTy, 1 , " mismatch_vec_found_pred" );
429
- FoundPred->addIncoming (VectorMatchCmp, VectorLoopStartBlock);
430
- PHINode *LastLoopPred =
431
- Builder.CreatePHI (PredVTy, 1 , " mismatch_vec_last_loop_pred" );
432
- LastLoopPred->addIncoming (LoopPred, VectorLoopStartBlock);
433
- PHINode *VectorFoundIndex =
434
- Builder.CreatePHI (I64Type, 1 , " mismatch_vec_found_index" );
435
- VectorFoundIndex->addIncoming (VectorIndexPhi, VectorLoopStartBlock);
436
-
437
- Value *PredMatchCmp = Builder.CreateAnd (LastLoopPred, FoundPred);
438
- Value *Ctz = Builder.CreateIntrinsic (
439
- Intrinsic::experimental_cttz_elts, {ResType , PredMatchCmp->getType ()},
440
- {PredMatchCmp, /* ZeroIsPoison=*/ Builder.getInt1 (true )});
441
- Ctz = Builder.CreateZExt (Ctz, I64Type);
442
- Value *VectorLoopRes64 = Builder.CreateAdd (VectorFoundIndex, Ctz, " " ,
443
- /* HasNUW=*/ true , /* HasNSW=*/ true );
444
- return Builder.CreateTrunc (VectorLoopRes64, ResType );
445
- }
446
-
447
334
Value *LoopIdiomVectorize::expandFindMismatch (
448
335
IRBuilder<> &Builder, DomTreeUpdater &DTU, GetElementPtrInst *GEPA,
449
336
GetElementPtrInst *GEPB, Instruction *Index, Value *Start, Value *MaxLen) {
@@ -458,7 +345,8 @@ Value *LoopIdiomVectorize::expandFindMismatch(
458
345
Type *ResType = Builder.getInt32Ty ();
459
346
460
347
// Split block in the original loop preheader.
461
- EndBlock = SplitBlock (Preheader, PHBranch, DT, LI, nullptr , " mismatch_end" );
348
+ BasicBlock *EndBlock =
349
+ SplitBlock (Preheader, PHBranch, DT, LI, nullptr , " mismatch_end" );
462
350
463
351
// Create the blocks that we're going to need:
464
352
// 1. A block for checking the zero-extended length exceeds 0
@@ -482,17 +370,17 @@ Value *LoopIdiomVectorize::expandFindMismatch(
482
370
BasicBlock *MemCheckBlock = BasicBlock::Create (
483
371
Ctx, " mismatch_mem_check" , EndBlock->getParent (), EndBlock);
484
372
485
- VectorLoopPreheaderBlock = BasicBlock::Create (
373
+ BasicBlock * VectorLoopPreheaderBlock = BasicBlock::Create (
486
374
Ctx, " mismatch_vec_loop_preheader" , EndBlock->getParent (), EndBlock);
487
375
488
- VectorLoopStartBlock = BasicBlock::Create (Ctx, " mismatch_vec_loop " ,
489
- EndBlock->getParent (), EndBlock);
376
+ BasicBlock * VectorLoopStartBlock = BasicBlock::Create (
377
+ Ctx, " mismatch_vec_loop " , EndBlock->getParent (), EndBlock);
490
378
491
- VectorLoopIncBlock = BasicBlock::Create (Ctx, " mismatch_vec_loop_inc " ,
492
- EndBlock->getParent (), EndBlock);
379
+ BasicBlock * VectorLoopIncBlock = BasicBlock::Create (
380
+ Ctx, " mismatch_vec_loop_inc " , EndBlock->getParent (), EndBlock);
493
381
494
- VectorLoopMismatchBlock = BasicBlock::Create (Ctx, " mismatch_vec_loop_found " ,
495
- EndBlock->getParent (), EndBlock);
382
+ BasicBlock * VectorLoopMismatchBlock = BasicBlock::Create (
383
+ Ctx, " mismatch_vec_loop_found " , EndBlock->getParent (), EndBlock);
496
384
497
385
BasicBlock *LoopPreHeaderBlock = BasicBlock::Create (
498
386
Ctx, " mismatch_loop_pre" , EndBlock->getParent (), EndBlock);
@@ -548,6 +436,10 @@ Value *LoopIdiomVectorize::expandFindMismatch(
548
436
MDBuilder (MinItCheckBr->getContext ()).createBranchWeights (99 , 1 ));
549
437
Builder.Insert (MinItCheckBr);
550
438
439
+ DTU.applyUpdates (
440
+ {{DominatorTree::Insert, MinItCheckBlock, MemCheckBlock},
441
+ {DominatorTree::Insert, MinItCheckBlock, LoopPreHeaderBlock}});
442
+
551
443
// For each of the arrays, check the start/end addresses are on the same
552
444
// page.
553
445
Builder.SetInsertPoint (MemCheckBlock);
@@ -590,20 +482,126 @@ Value *LoopIdiomVectorize::expandFindMismatch(
590
482
.createBranchWeights (10 , 90 ));
591
483
Builder.Insert (CombinedPageCmpCmpBr);
592
484
485
+ DTU.applyUpdates (
486
+ {{DominatorTree::Insert, MemCheckBlock, LoopPreHeaderBlock},
487
+ {DominatorTree::Insert, MemCheckBlock, VectorLoopPreheaderBlock}});
488
+
593
489
// Set up the vector loop preheader, i.e. calculate initial loop predicate,
594
490
// zero-extend MaxLen to 64-bits, determine the number of vector elements
595
491
// processed in each iteration, etc.
596
492
Builder.SetInsertPoint (VectorLoopPreheaderBlock);
597
493
598
- Value *VectorLoopRes =
599
- createMaskedFindMismatch (Builder, GEPA, GEPB, ExtStart, ExtEnd);
494
+ // At this point we know two things must be true:
495
+ // 1. Start <= End
496
+ // 2. ExtMaxLen <= MinPageSize due to the page checks.
497
+ // Therefore, we know that we can use a 64-bit induction variable that
498
+ // starts from 0 -> ExtMaxLen and it will not overflow.
499
+ ScalableVectorType *PredVTy =
500
+ ScalableVectorType::get (Builder.getInt1Ty (), 16 );
501
+
502
+ Value *InitialPred = Builder.CreateIntrinsic (
503
+ Intrinsic::get_active_lane_mask, {PredVTy, I64Type}, {ExtStart, ExtEnd});
504
+
505
+ Value *VecLen = Builder.CreateIntrinsic (Intrinsic::vscale, {I64Type}, {});
506
+ VecLen = Builder.CreateMul (VecLen, ConstantInt::get (I64Type, 16 ), " " ,
507
+ /* HasNUW=*/ true , /* HasNSW=*/ true );
508
+
509
+ Value *PFalse = Builder.CreateVectorSplat (PredVTy->getElementCount (),
510
+ Builder.getInt1 (false ));
511
+
512
+ BranchInst *JumpToVectorLoop = BranchInst::Create (VectorLoopStartBlock);
513
+ Builder.Insert (JumpToVectorLoop);
514
+
515
+ DTU.applyUpdates ({{DominatorTree::Insert, VectorLoopPreheaderBlock,
516
+ VectorLoopStartBlock}});
517
+
518
+ // Set up the first vector loop block by creating the PHIs, doing the vector
519
+ // loads and comparing the vectors.
520
+ Builder.SetInsertPoint (VectorLoopStartBlock);
521
+ PHINode *LoopPred = Builder.CreatePHI (PredVTy, 2 , " mismatch_vec_loop_pred" );
522
+ LoopPred->addIncoming (InitialPred, VectorLoopPreheaderBlock);
523
+ PHINode *VectorIndexPhi = Builder.CreatePHI (I64Type, 2 , " mismatch_vec_index" );
524
+ VectorIndexPhi->addIncoming (ExtStart, VectorLoopPreheaderBlock);
525
+ Type *VectorLoadType = ScalableVectorType::get (Builder.getInt8Ty (), 16 );
526
+ Value *Passthru = ConstantInt::getNullValue (VectorLoadType);
527
+
528
+ Value *VectorLhsGep =
529
+ Builder.CreateGEP (LoadType, PtrA, VectorIndexPhi, " " , GEPA->isInBounds ());
530
+ Value *VectorLhsLoad = Builder.CreateMaskedLoad (VectorLoadType, VectorLhsGep,
531
+ Align (1 ), LoopPred, Passthru);
532
+
533
+ Value *VectorRhsGep =
534
+ Builder.CreateGEP (LoadType, PtrB, VectorIndexPhi, " " , GEPB->isInBounds ());
535
+ Value *VectorRhsLoad = Builder.CreateMaskedLoad (VectorLoadType, VectorRhsGep,
536
+ Align (1 ), LoopPred, Passthru);
537
+
538
+ Value *VectorMatchCmp = Builder.CreateICmpNE (VectorLhsLoad, VectorRhsLoad);
539
+ VectorMatchCmp = Builder.CreateSelect (LoopPred, VectorMatchCmp, PFalse);
540
+ Value *VectorMatchHasActiveLanes = Builder.CreateOrReduce (VectorMatchCmp);
541
+ BranchInst *VectorEarlyExit = BranchInst::Create (
542
+ VectorLoopMismatchBlock, VectorLoopIncBlock, VectorMatchHasActiveLanes);
543
+ Builder.Insert (VectorEarlyExit);
544
+
545
+ DTU.applyUpdates (
546
+ {{DominatorTree::Insert, VectorLoopStartBlock, VectorLoopMismatchBlock},
547
+ {DominatorTree::Insert, VectorLoopStartBlock, VectorLoopIncBlock}});
548
+
549
+ // Increment the index counter and calculate the predicate for the next
550
+ // iteration of the loop. We branch back to the start of the loop if there
551
+ // is at least one active lane.
552
+ Builder.SetInsertPoint (VectorLoopIncBlock);
553
+ Value *NewVectorIndexPhi =
554
+ Builder.CreateAdd (VectorIndexPhi, VecLen, " " ,
555
+ /* HasNUW=*/ true , /* HasNSW=*/ true );
556
+ VectorIndexPhi->addIncoming (NewVectorIndexPhi, VectorLoopIncBlock);
557
+ Value *NewPred =
558
+ Builder.CreateIntrinsic (Intrinsic::get_active_lane_mask,
559
+ {PredVTy, I64Type}, {NewVectorIndexPhi, ExtEnd});
560
+ LoopPred->addIncoming (NewPred, VectorLoopIncBlock);
561
+
562
+ Value *PredHasActiveLanes =
563
+ Builder.CreateExtractElement (NewPred, uint64_t (0 ));
564
+ BranchInst *VectorLoopBranchBack =
565
+ BranchInst::Create (VectorLoopStartBlock, EndBlock, PredHasActiveLanes);
566
+ Builder.Insert (VectorLoopBranchBack);
567
+
568
+ DTU.applyUpdates (
569
+ {{DominatorTree::Insert, VectorLoopIncBlock, VectorLoopStartBlock},
570
+ {DominatorTree::Insert, VectorLoopIncBlock, EndBlock}});
571
+
572
+ // If we found a mismatch then we need to calculate which lane in the vector
573
+ // had a mismatch and add that on to the current loop index.
574
+ Builder.SetInsertPoint (VectorLoopMismatchBlock);
575
+ PHINode *FoundPred = Builder.CreatePHI (PredVTy, 1 , " mismatch_vec_found_pred" );
576
+ FoundPred->addIncoming (VectorMatchCmp, VectorLoopStartBlock);
577
+ PHINode *LastLoopPred =
578
+ Builder.CreatePHI (PredVTy, 1 , " mismatch_vec_last_loop_pred" );
579
+ LastLoopPred->addIncoming (LoopPred, VectorLoopStartBlock);
580
+ PHINode *VectorFoundIndex =
581
+ Builder.CreatePHI (I64Type, 1 , " mismatch_vec_found_index" );
582
+ VectorFoundIndex->addIncoming (VectorIndexPhi, VectorLoopStartBlock);
583
+
584
+ Value *PredMatchCmp = Builder.CreateAnd (LastLoopPred, FoundPred);
585
+ Value *Ctz = Builder.CreateIntrinsic (
586
+ Intrinsic::experimental_cttz_elts, {ResType , PredMatchCmp->getType ()},
587
+ {PredMatchCmp, /* ZeroIsPoison=*/ Builder.getInt1 (true )});
588
+ Ctz = Builder.CreateZExt (Ctz, I64Type);
589
+ Value *VectorLoopRes64 = Builder.CreateAdd (VectorFoundIndex, Ctz, " " ,
590
+ /* HasNUW=*/ true , /* HasNSW=*/ true );
591
+ Value *VectorLoopRes = Builder.CreateTrunc (VectorLoopRes64, ResType );
600
592
601
593
Builder.Insert (BranchInst::Create (EndBlock));
602
594
595
+ DTU.applyUpdates (
596
+ {{DominatorTree::Insert, VectorLoopMismatchBlock, EndBlock}});
597
+
603
598
// Generate code for scalar loop.
604
599
Builder.SetInsertPoint (LoopPreHeaderBlock);
605
600
Builder.Insert (BranchInst::Create (LoopStartBlock));
606
601
602
+ DTU.applyUpdates (
603
+ {{DominatorTree::Insert, LoopPreHeaderBlock, LoopStartBlock}});
604
+
607
605
Builder.SetInsertPoint (LoopStartBlock);
608
606
PHINode *IndexPhi = Builder.CreatePHI (ResType , 2 , " mismatch_index" );
609
607
IndexPhi->addIncoming (Start, LoopPreHeaderBlock);
@@ -625,6 +623,9 @@ Value *LoopIdiomVectorize::expandFindMismatch(
625
623
BranchInst *MatchCmpBr = BranchInst::Create (LoopIncBlock, EndBlock, MatchCmp);
626
624
Builder.Insert (MatchCmpBr);
627
625
626
+ DTU.applyUpdates ({{DominatorTree::Insert, LoopStartBlock, LoopIncBlock},
627
+ {DominatorTree::Insert, LoopStartBlock, EndBlock}});
628
+
628
629
// Have we reached the maximum permitted length for the loop?
629
630
Builder.SetInsertPoint (LoopIncBlock);
630
631
Value *PhiInc = Builder.CreateAdd (IndexPhi, ConstantInt::get (ResType , 1 ), " " ,
@@ -635,6 +636,9 @@ Value *LoopIdiomVectorize::expandFindMismatch(
635
636
BranchInst *IVCmpBr = BranchInst::Create (EndBlock, LoopStartBlock, IVCmp);
636
637
Builder.Insert (IVCmpBr);
637
638
639
+ DTU.applyUpdates ({{DominatorTree::Insert, LoopIncBlock, EndBlock},
640
+ {DominatorTree::Insert, LoopIncBlock, LoopStartBlock}});
641
+
638
642
// In the end block we need to insert a PHI node to deal with three cases:
639
643
// 1. We didn't find a mismatch in the scalar loop, so we return MaxLen.
640
644
// 2. We exitted the scalar loop early due to a mismatch and need to return
@@ -678,11 +682,6 @@ void LoopIdiomVectorize::transformByteCompare(GetElementPtrInst *GEPA,
678
682
DomTreeUpdater DTU (DT, DomTreeUpdater::UpdateStrategy::Lazy);
679
683
Builder.SetCurrentDebugLocation (PHBranch->getDebugLoc ());
680
684
681
- // Safeguard to check if we build the correct DomTree with DTU.
682
- auto CheckDTU = llvm::make_scope_exit ([&]() {
683
- assert (DTU.getDomTree ().verify () && " Ill-formed DomTree built by DTU" );
684
- });
685
-
686
685
// Increment the pointer if this was done before the loads in the loop.
687
686
if (IncIdx)
688
687
Start = Builder.CreateAdd (Start, ConstantInt::get (Start->getType (), 1 ));
@@ -718,8 +717,12 @@ void LoopIdiomVectorize::transformByteCompare(GetElementPtrInst *GEPA,
718
717
if (FoundBB != EndBB) {
719
718
Value *FoundCmp = Builder.CreateICmpEQ (ByteCmpRes, MaxLen);
720
719
Builder.CreateCondBr (FoundCmp, EndBB, FoundBB);
720
+ DTU.applyUpdates ({{DominatorTree::Insert, CmpBB, FoundBB},
721
+ {DominatorTree::Insert, CmpBB, EndBB}});
722
+
721
723
} else {
722
724
Builder.CreateBr (FoundBB);
725
+ DTU.applyUpdates ({{DominatorTree::Insert, CmpBB, FoundBB}});
723
726
}
724
727
725
728
auto fixSuccessorPhis = [&](BasicBlock *SuccBB) {
0 commit comments