@@ -1936,10 +1936,6 @@ class GeneratedRTChecks {
1936
1936
OuterLoop = L->getParentLoop ();
1937
1937
}
1938
1938
1939
- Value *expandCodeForMemCheck (const SCEV *Scev, Instruction *Loc) {
1940
- return MemCheckExp.expandCodeFor (Scev, Scev->getType (), Loc);
1941
- }
1942
-
1943
1939
InstructionCost getCost () {
1944
1940
if (SCEVCheckBlock || MemCheckBlock)
1945
1941
LLVM_DEBUG (dbgs () << " Calculating cost of runtime checks:\n " );
@@ -6905,10 +6901,9 @@ LoopVectorizationPlanner::planInVPlanNativePath(ElementCount UserVF) {
6905
6901
return VectorizationFactor::Disabled ();
6906
6902
}
6907
6903
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) {
6912
6907
assert (OrigLoop->isInnermost () && " Inner loop expected." );
6913
6908
CM.collectValuesToIgnore ();
6914
6909
CM.collectElementTypesForWidening ();
@@ -6919,15 +6914,9 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC,
6919
6914
6920
6915
// VPlan needs the aliasing pointers as Values and not SCEVs, so expand them
6921
6916
// 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;
6931
6920
6932
6921
// Invalidate interleave groups if all blocks of loop will be predicated.
6933
6922
if (CM.blockNeedsPredicationForAnyReason (OrigLoop->getHeader ()) &&
@@ -6957,7 +6946,7 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC,
6957
6946
CM.collectInLoopReductions ();
6958
6947
if (CM.selectUserVectorizationFactor (UserVF)) {
6959
6948
LLVM_DEBUG (dbgs () << " LV: Using user VF " << UserVF << " .\n " );
6960
- buildVPlansWithVPRecipes (UserVF, UserVF, DiffChecksValues , HasAliasMask);
6949
+ buildVPlansWithVPRecipes (UserVF, UserVF, DiffChecks , HasAliasMask);
6961
6950
if (!hasPlanWithVF (UserVF)) {
6962
6951
LLVM_DEBUG (dbgs () << " LV: No VPlan could be built for " << UserVF
6963
6952
<< " .\n " );
@@ -6992,9 +6981,9 @@ LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC,
6992
6981
}
6993
6982
6994
6983
buildVPlansWithVPRecipes (ElementCount::getFixed (1 ), MaxFactors.FixedVF ,
6995
- DiffChecksValues , HasAliasMask);
6984
+ DiffChecks , HasAliasMask);
6996
6985
buildVPlansWithVPRecipes (ElementCount::getScalable (1 ), MaxFactors.ScalableVF ,
6997
- DiffChecksValues , HasAliasMask);
6986
+ DiffChecks , HasAliasMask);
6998
6987
6999
6988
LLVM_DEBUG (printPlans (dbgs ()));
7000
6989
if (VPlans.empty ())
@@ -8387,8 +8376,8 @@ VPRecipeBuilder::tryToCreateWidenRecipe(Instruction *Instr,
8387
8376
}
8388
8377
8389
8378
void LoopVectorizationPlanner::buildVPlansWithVPRecipes (
8390
- ElementCount MinVF, ElementCount MaxVF,
8391
- SmallVector<PointerDiffInfoValues> RTChecks, bool &HasAliasMask) {
8379
+ ElementCount MinVF, ElementCount MaxVF, ArrayRef<PointerDiffInfo> RTChecks,
8380
+ bool &HasAliasMask) {
8392
8381
assert (OrigLoop->isInnermost () && " Inner loop expected." );
8393
8382
8394
8383
auto MaxVFTimes2 = MaxVF * 2 ;
@@ -8534,8 +8523,7 @@ static void addLiveOutsForFirstOrderRecurrences(VPlan &Plan) {
8534
8523
}
8535
8524
8536
8525
VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes (
8537
- VFRange &Range, SmallVector<PointerDiffInfoValues> RTChecks,
8538
- bool &HasAliasMask) {
8526
+ VFRange &Range, ArrayRef<PointerDiffInfo> RTChecks, bool &HasAliasMask) {
8539
8527
8540
8528
SmallPtrSet<const InterleaveGroup<Instruction> *, 1 > InterleaveGroups;
8541
8529
@@ -8584,8 +8572,10 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
8584
8572
VPBuilder Builder (VecPreheader);
8585
8573
for (auto C : RTChecks) {
8586
8574
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 ());
8589
8579
VPValue *M =
8590
8580
Builder.createNaryOp (VPInstruction::AliasLaneMask, {Sink, Src}, DL,
8591
8581
" active.lane.mask.alias" );
@@ -9921,11 +9911,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
9921
9911
AddBranchWeights);
9922
9912
9923
9913
// 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
- };
9927
9914
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 );
9929
9918
if (Checks.HasAliasMask )
9930
9919
LoopsAliasMasked++;
9931
9920
0 commit comments