Skip to content

Commit 50515db

Browse files
committed
[SLP][NFC]Format canVectorizeLoads after previous NFC patches.
1 parent 606a934 commit 50515db

File tree

1 file changed

+31
-34
lines changed

1 file changed

+31
-34
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4757,13 +4757,12 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
47574757
});
47584758
});
47594759
const unsigned AbsoluteDiff = std::abs(*Diff);
4760-
if (IsPossibleStrided &&
4761-
(IsAnyPointerUsedOutGraph ||
4762-
((Sz > MinProfitableStridedLoads ||
4763-
(AbsoluteDiff <= MaxProfitableLoadStride * Sz &&
4764-
has_single_bit(AbsoluteDiff))) &&
4765-
AbsoluteDiff > Sz) ||
4766-
*Diff == -(static_cast<int>(Sz) - 1))) {
4760+
if (IsPossibleStrided && (IsAnyPointerUsedOutGraph ||
4761+
((Sz > MinProfitableStridedLoads ||
4762+
(AbsoluteDiff <= MaxProfitableLoadStride * Sz &&
4763+
has_single_bit(AbsoluteDiff))) &&
4764+
AbsoluteDiff > Sz) ||
4765+
*Diff == -(static_cast<int>(Sz) - 1))) {
47674766
int Stride = *Diff / static_cast<int>(Sz - 1);
47684767
if (*Diff == Stride * static_cast<int>(Sz - 1)) {
47694768
Align Alignment =
@@ -4778,8 +4777,7 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
47784777
if (Ptr == PtrN)
47794778
Dist = *Diff;
47804779
else if (Ptr != Ptr0)
4781-
Dist =
4782-
*getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, *DL, *SE);
4780+
Dist = *getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, *DL, *SE);
47834781
// If the strides are not the same or repeated, we can't
47844782
// vectorize.
47854783
if (((Dist / Stride) * Stride) != Dist ||
@@ -4822,14 +4820,14 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
48224820
if (VectorizedCnt == VL.size() / VF) {
48234821
// Compare masked gather cost and loads + insersubvector costs.
48244822
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
4825-
auto [ScalarGEPCost, VectorGEPCost] = getGEPCosts(
4826-
TTI, PointerOps, PointerOps.front(), Instruction::GetElementPtr,
4827-
CostKind, ScalarTy, VecTy);
4823+
auto [ScalarGEPCost, VectorGEPCost] =
4824+
getGEPCosts(TTI, PointerOps, PointerOps.front(),
4825+
Instruction::GetElementPtr, CostKind, ScalarTy, VecTy);
48284826
InstructionCost MaskedGatherCost =
4829-
TTI.getGatherScatterOpCost(
4830-
Instruction::Load, VecTy,
4831-
cast<LoadInst>(VL0)->getPointerOperand(),
4832-
/*VariableMask=*/false, CommonAlignment, CostKind) +
4827+
TTI.getGatherScatterOpCost(Instruction::Load, VecTy,
4828+
cast<LoadInst>(VL0)->getPointerOperand(),
4829+
/*VariableMask=*/false, CommonAlignment,
4830+
CostKind) +
48334831
VectorGEPCost - ScalarGEPCost;
48344832
InstructionCost VecLdCost = 0;
48354833
auto *SubVecTy = getWidenedType(ScalarTy, VF);
@@ -4853,23 +4851,23 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
48534851
getGEPCosts(TTI, ArrayRef(PointerOps).slice(I * VF, VF),
48544852
LI0->getPointerOperand(), Instruction::Load,
48554853
CostKind, ScalarTy, SubVecTy);
4856-
VecLdCost +=
4857-
TTI.getStridedMemoryOpCost(
4858-
Instruction::Load, SubVecTy, LI0->getPointerOperand(),
4859-
/*VariableMask=*/false, CommonAlignment, CostKind) +
4860-
VectorGEPCost - ScalarGEPCost;
4854+
VecLdCost += TTI.getStridedMemoryOpCost(Instruction::Load, SubVecTy,
4855+
LI0->getPointerOperand(),
4856+
/*VariableMask=*/false,
4857+
CommonAlignment, CostKind) +
4858+
VectorGEPCost - ScalarGEPCost;
48614859
break;
48624860
}
48634861
case LoadsState::ScatterVectorize: {
48644862
auto [ScalarGEPCost, VectorGEPCost] = getGEPCosts(
48654863
TTI, ArrayRef(PointerOps).slice(I * VF, VF),
4866-
LI0->getPointerOperand(), Instruction::GetElementPtr,
4867-
CostKind, ScalarTy, SubVecTy);
4868-
VecLdCost +=
4869-
TTI.getGatherScatterOpCost(
4870-
Instruction::Load, SubVecTy, LI0->getPointerOperand(),
4871-
/*VariableMask=*/false, CommonAlignment, CostKind) +
4872-
VectorGEPCost - ScalarGEPCost;
4864+
LI0->getPointerOperand(), Instruction::GetElementPtr, CostKind,
4865+
ScalarTy, SubVecTy);
4866+
VecLdCost += TTI.getGatherScatterOpCost(Instruction::Load, SubVecTy,
4867+
LI0->getPointerOperand(),
4868+
/*VariableMask=*/false,
4869+
CommonAlignment, CostKind) +
4870+
VectorGEPCost - ScalarGEPCost;
48734871
break;
48744872
}
48754873
case LoadsState::Gather:
@@ -4880,8 +4878,8 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
48804878
for (int Idx : seq<int>(0, VL.size()))
48814879
ShuffleMask[Idx] = Idx / VF == I ? VL.size() + Idx % VF : Idx;
48824880
VecLdCost +=
4883-
::getShuffleCost(TTI, TTI::SK_InsertSubvector, VecTy,
4884-
ShuffleMask, CostKind, I * VF, SubVecTy);
4881+
::getShuffleCost(TTI, TTI::SK_InsertSubvector, VecTy, ShuffleMask,
4882+
CostKind, I * VF, SubVecTy);
48854883
}
48864884
// If masked gather cost is higher - better to vectorize, so
48874885
// consider it as a gather node. It will be better estimated
@@ -4897,10 +4895,9 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
48974895
// increases the cost.
48984896
Loop *L = LI->getLoopFor(cast<LoadInst>(VL0)->getParent());
48994897
bool ProfitableGatherPointers =
4900-
L && Sz > 2 &&
4901-
static_cast<unsigned>(count_if(PointerOps, [L](Value *V) {
4902-
return L->isLoopInvariant(V);
4903-
})) <= Sz / 2;
4898+
L && Sz > 2 && static_cast<unsigned>(count_if(PointerOps, [L](Value *V) {
4899+
return L->isLoopInvariant(V);
4900+
})) <= Sz / 2;
49044901
if (ProfitableGatherPointers || all_of(PointerOps, [IsSorted](Value *P) {
49054902
auto *GEP = dyn_cast<GetElementPtrInst>(P);
49064903
return (IsSorted && !GEP && doesNotNeedToBeScheduled(P)) ||

0 commit comments

Comments
 (0)