@@ -1936,10 +1936,6 @@ class GeneratedRTChecks {
19361936 OuterLoop = L->getParentLoop ();
19371937 }
19381938
1939- Value *expandCodeForMemCheck (const SCEV *Scev, Instruction *Loc) {
1940- return MemCheckExp.expandCodeFor (Scev, Scev->getType (), Loc);
1941- }
1942-
19431939 InstructionCost getCost () {
19441940 if (SCEVCheckBlock || MemCheckBlock)
19451941 LLVM_DEBUG (dbgs () << " Calculating cost of runtime checks:\n " );
@@ -6905,10 +6901,9 @@ LoopVectorizationPlanner::planInVPlanNativePath(ElementCount UserVF) {
69056901 return VectorizationFactor::Disabled ();
69066902}
69076903
6908- std::optional<VectorizationFactor>
6909- LoopVectorizationPlanner::plan (ElementCount UserVF, unsigned UserIC,
6910- std::optional<ArrayRef<PointerDiffInfo>> RTChecks,
6911- std::function<Value*(const SCEV*)> Expander, bool &HasAliasMask) {
6904+ std::optional<VectorizationFactor> LoopVectorizationPlanner::plan (
6905+ ElementCount UserVF, unsigned UserIC,
6906+ std::optional<ArrayRef<PointerDiffInfo>> RTChecks, bool &HasAliasMask) {
69126907 assert (OrigLoop->isInnermost () && " Inner loop expected." );
69136908 CM.collectValuesToIgnore ();
69146909 CM.collectElementTypesForWidening ();
@@ -6919,15 +6914,9 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC,
69196914
69206915 // VPlan needs the aliasing pointers as Values and not SCEVs, so expand them
69216916 // here and put them into a list.
6922- SmallVector<PointerDiffInfoValues> DiffChecksValues;
6923- if (RTChecks.has_value ()
6924- && useActiveLaneMask (CM.getTailFoldingStyle (true ))) {
6925- for (auto Check : *RTChecks) {
6926- Value *Sink = Expander (Check.SinkStart );
6927- Value *Src = Expander (Check.SrcStart );
6928- DiffChecksValues.push_back (PointerDiffInfoValues (Src, Sink));
6929- }
6930- }
6917+ ArrayRef<PointerDiffInfo> DiffChecks;
6918+ if (RTChecks.has_value () && useActiveLaneMask (CM.getTailFoldingStyle (true )))
6919+ DiffChecks = *RTChecks;
69316920
69326921 // Invalidate interleave groups if all blocks of loop will be predicated.
69336922 if (CM.blockNeedsPredicationForAnyReason (OrigLoop->getHeader ()) &&
@@ -6957,7 +6946,7 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC,
69576946 CM.collectInLoopReductions ();
69586947 if (CM.selectUserVectorizationFactor (UserVF)) {
69596948 LLVM_DEBUG (dbgs () << " LV: Using user VF " << UserVF << " .\n " );
6960- buildVPlansWithVPRecipes (UserVF, UserVF, DiffChecksValues , HasAliasMask);
6949+ buildVPlansWithVPRecipes (UserVF, UserVF, DiffChecks , HasAliasMask);
69616950 if (!hasPlanWithVF (UserVF)) {
69626951 LLVM_DEBUG (dbgs () << " LV: No VPlan could be built for " << UserVF
69636952 << " .\n " );
@@ -6992,9 +6981,9 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC,
69926981 }
69936982
69946983 buildVPlansWithVPRecipes (ElementCount::getFixed (1 ), MaxFactors.FixedVF ,
6995- DiffChecksValues , HasAliasMask);
6984+ DiffChecks , HasAliasMask);
69966985 buildVPlansWithVPRecipes (ElementCount::getScalable (1 ), MaxFactors.ScalableVF ,
6997- DiffChecksValues , HasAliasMask);
6986+ DiffChecks , HasAliasMask);
69986987
69996988 LLVM_DEBUG (printPlans (dbgs ()));
70006989 if (VPlans.empty ())
@@ -8387,8 +8376,8 @@ VPRecipeBuilder::tryToCreateWidenRecipe(Instruction *Instr,
83878376}
83888377
83898378void LoopVectorizationPlanner::buildVPlansWithVPRecipes (
8390- ElementCount MinVF, ElementCount MaxVF,
8391- SmallVector<PointerDiffInfoValues> RTChecks, bool &HasAliasMask) {
8379+ ElementCount MinVF, ElementCount MaxVF, ArrayRef<PointerDiffInfo> RTChecks,
8380+ bool &HasAliasMask) {
83928381 assert (OrigLoop->isInnermost () && " Inner loop expected." );
83938382
83948383 auto MaxVFTimes2 = MaxVF * 2 ;
@@ -8534,8 +8523,7 @@ static void addLiveOutsForFirstOrderRecurrences(VPlan &Plan) {
85348523}
85358524
85368525VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes (
8537- VFRange &Range, SmallVector<PointerDiffInfoValues> RTChecks,
8538- bool &HasAliasMask) {
8526+ VFRange &Range, ArrayRef<PointerDiffInfo> RTChecks, bool &HasAliasMask) {
85398527
85408528 SmallPtrSet<const InterleaveGroup<Instruction> *, 1 > InterleaveGroups;
85418529
@@ -8584,8 +8572,10 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
85848572 VPBuilder Builder (VecPreheader);
85858573 for (auto C : RTChecks) {
85868574 HasAliasMask = true ;
8587- VPValue *Sink = Plan->getOrAddLiveIn (C.Sink );
8588- VPValue *Src = Plan->getOrAddLiveIn (C.Src );
8575+ VPValue *Sink = vputils::getOrCreateVPValueForSCEVExpr (*Plan, C.SinkStart ,
8576+ *PSE.getSE ());
8577+ VPValue *Src = vputils::getOrCreateVPValueForSCEVExpr (*Plan, C.SrcStart ,
8578+ *PSE.getSE ());
85898579 VPValue *M =
85908580 Builder.createNaryOp (VPInstruction::AliasLaneMask, {Sink, Src}, DL,
85918581 " active.lane.mask.alias" );
@@ -9921,11 +9911,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
99219911 AddBranchWeights);
99229912
99239913 // Plan how to best vectorize, return the best VF and its cost.
9924- auto Expand = [&Checks, &L](const SCEV *S) {
9925- return Checks.expandCodeForMemCheck (S, L->getLoopPreheader ()->getTerminator ());
9926- };
99279914 std::optional<VectorizationFactor> MaybeVF =
9928- LVP.plan (UserVF, UserIC, LVL.getLAI ()->getRuntimePointerChecking ()->getDiffChecks (), Expand, Checks.HasAliasMask );
9915+ LVP.plan (UserVF, UserIC,
9916+ LVL.getLAI ()->getRuntimePointerChecking ()->getDiffChecks (),
9917+ Checks.HasAliasMask );
99299918 if (Checks.HasAliasMask )
99309919 LoopsAliasMasked++;
99319920
0 commit comments