@@ -2396,6 +2396,7 @@ void InnerLoopVectorizer::emitIterationCountCheck(BasicBlock *Bypass) {
23962396 LoopVectorPreHeader = SplitBlock (TCCheckBlock, TCCheckBlock->getTerminator (),
23972397 static_cast <DominatorTree *>(nullptr ), LI,
23982398 nullptr , " vector.ph" );
2399+
23992400 BranchInst &BI =
24002401 *BranchInst::Create (Bypass, LoopVectorPreHeader, CheckMinIters);
24012402 if (hasBranchWeightMD (*OrigLoop->getLoopLatch ()->getTerminator ()))
@@ -6730,12 +6731,6 @@ void LoopVectorizationPlanner::plan(
67306731 if (!MaxFactors) // Cases that should not to be vectorized nor interleaved.
67316732 return ;
67326733
6733- ArrayRef<PointerDiffInfo> DiffChecks;
6734- auto TFStyle = CM.getTailFoldingStyle ();
6735- if (RTChecks.has_value () &&
6736- useSafeEltsMask (TFStyle, CM.getRTCheckStyle (TFStyle), TTI))
6737- DiffChecks = *RTChecks;
6738-
67396734 // Invalidate interleave groups if all blocks of loop will be predicated.
67406735 if (CM.blockNeedsPredicationForAnyReason (OrigLoop->getHeader ()) &&
67416736 !useMaskedInterleavedAccesses (TTI)) {
@@ -6768,7 +6763,7 @@ void LoopVectorizationPlanner::plan(
67686763 CM.collectInLoopReductions ();
67696764 if (CM.selectUserVectorizationFactor (UserVF)) {
67706765 LLVM_DEBUG (dbgs () << " LV: Using user VF " << UserVF << " .\n " );
6771- buildVPlansWithVPRecipes (UserVF, UserVF, DiffChecks );
6766+ buildVPlansWithVPRecipes (UserVF, UserVF);
67726767 LLVM_DEBUG (printPlans (dbgs ()));
67736768 return ;
67746769 }
@@ -6792,10 +6787,8 @@ void LoopVectorizationPlanner::plan(
67926787 CM.collectNonVectorizedAndSetWideningDecisions (VF);
67936788 }
67946789
6795- buildVPlansWithVPRecipes (ElementCount::getFixed (1 ), MaxFactors.FixedVF ,
6796- DiffChecks);
6797- buildVPlansWithVPRecipes (ElementCount::getScalable (1 ), MaxFactors.ScalableVF ,
6798- DiffChecks);
6790+ buildVPlansWithVPRecipes (ElementCount::getFixed (1 ), MaxFactors.FixedVF );
6791+ buildVPlansWithVPRecipes (ElementCount::getScalable (1 ), MaxFactors.ScalableVF );
67996792
68006793 LLVM_DEBUG (printPlans (dbgs ()));
68016794}
@@ -8402,9 +8395,8 @@ VPRecipeBuilder::tryToCreatePartialReduction(Instruction *Reduction,
84028395 ScaleFactor, Reduction);
84038396}
84048397
8405- void LoopVectorizationPlanner::buildVPlansWithVPRecipes (
8406- ElementCount MinVF, ElementCount MaxVF,
8407- ArrayRef<PointerDiffInfo> DiffChecks) {
8398+ void LoopVectorizationPlanner::buildVPlansWithVPRecipes (ElementCount MinVF,
8399+ ElementCount MaxVF) {
84088400 if (ElementCount::isKnownGT (MinVF, MaxVF))
84098401 return ;
84108402
@@ -8430,8 +8422,7 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(
84308422 for (ElementCount VF = MinVF; ElementCount::isKnownLT (VF, MaxVFTimes2);) {
84318423 VFRange SubRange = {VF, MaxVFTimes2};
84328424 if (auto Plan = tryToBuildVPlanWithVPRecipes (
8433- std::unique_ptr<VPlan>(VPlan0->duplicate ()), SubRange, &LVer,
8434- DiffChecks)) {
8425+ std::unique_ptr<VPlan>(VPlan0->duplicate ()), SubRange, &LVer)) {
84358426 bool HasScalarVF = Plan->hasScalarVFOnly ();
84368427 // Now optimize the initial VPlan.
84378428 if (!HasScalarVF)
@@ -8656,8 +8647,7 @@ static void addExitUsersForFirstOrderRecurrences(VPlan &Plan, VFRange &Range) {
86568647}
86578648
86588649VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes (
8659- VPlanPtr Plan, VFRange &Range, LoopVersioning *LVer,
8660- ArrayRef<PointerDiffInfo> DiffChecks) {
8650+ VPlanPtr Plan, VFRange &Range, LoopVersioning *LVer) {
86618651
86628652 using namespace llvm ::VPlanPatternMatch;
86638653 SmallPtrSet<const InterleaveGroup<Instruction> *, 1 > InterleaveGroups;
@@ -8945,6 +8935,14 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
89458935 bool ForControlFlow = useActiveLaneMaskForControlFlow (Style);
89468936 bool WithoutRuntimeCheck =
89478937 Style == TailFoldingStyle::DataAndControlFlowWithoutRuntimeCheck;
8938+
8939+ ArrayRef<PointerDiffInfo> DiffChecks;
8940+ std::optional<ArrayRef<PointerDiffInfo>> RTChecks =
8941+ CM.Legal ->getRuntimePointerChecking ()->getDiffChecks ();
8942+ if (RTChecks.has_value () &&
8943+ useSafeEltsMask (Style, CM.getRTCheckStyle (Style), TTI))
8944+ DiffChecks = *RTChecks;
8945+
89488946 VPlanTransforms::addActiveLaneMask (*Plan, ForControlFlow,
89498947 WithoutRuntimeCheck, PSE, DiffChecks);
89508948 }
0 commit comments