Skip to content

Commit 299e5fe

Browse files
committed
[SLP][NFC]Simplify/unify vectors for scattered/vectorized loads from
gathers, NFC.
1 parent 3885483 commit 299e5fe

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7090,8 +7090,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
70907090
!all_of(Gathers, [&](Value *V) { return R.getTreeEntry(V); }) &&
70917091
!isSplat(Gathers)) {
70927092
SetVector<Value *> VectorizedLoads;
7093-
SmallVector<LoadInst *> VectorizedStarts;
7094-
SmallVector<std::pair<unsigned, unsigned>> ScatterVectorized;
7093+
SmallVector<unsigned> VectorizedStarts;
7094+
SmallVector<unsigned> ScatterVectorized;
70957095
unsigned StartIdx = 0;
70967096
unsigned VF = VL.size() / 2;
70977097
for (; VF >= MinVF; VF /= 2) {
@@ -7119,9 +7119,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
71197119
// again.
71207120
// TODO: better handling of loads with reorders.
71217121
if (LS == LoadsState::Vectorize && CurrentOrder.empty())
7122-
VectorizedStarts.push_back(cast<LoadInst>(Slice.front()));
7122+
VectorizedStarts.push_back(Cnt);
71237123
else
7124-
ScatterVectorized.emplace_back(Cnt, VF);
7124+
ScatterVectorized.push_back(Cnt);
71257125
VectorizedLoads.insert(Slice.begin(), Slice.end());
71267126
// If we vectorized initial block, no need to try to vectorize
71277127
// it again.
@@ -7163,17 +7163,18 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
71637163
CostKind, TTI::OperandValueInfo(), LI);
71647164
}
71657165
auto *LoadTy = FixedVectorType::get(VL.front()->getType(), VF);
7166-
for (LoadInst *LI : VectorizedStarts) {
7166+
for (unsigned P : VectorizedStarts) {
7167+
auto *LI = cast<LoadInst>(VL[P]);
71677168
Align Alignment = LI->getAlign();
71687169
GatherCost +=
71697170
TTI.getMemoryOpCost(Instruction::Load, LoadTy, Alignment,
71707171
LI->getPointerAddressSpace(), CostKind,
71717172
TTI::OperandValueInfo(), LI);
71727173
}
7173-
for (std::pair<unsigned, unsigned> P : ScatterVectorized) {
7174-
auto *LI0 = cast<LoadInst>(VL[P.first]);
7174+
for (unsigned P : ScatterVectorized) {
7175+
auto *LI0 = cast<LoadInst>(VL[P]);
71757176
Align CommonAlignment =
7176-
computeCommonAlignment<LoadInst>(VL.slice(P.first + 1, VF - 1));
7177+
computeCommonAlignment<LoadInst>(VL.slice(P, VF));
71777178
GatherCost += TTI.getGatherScatterOpCost(
71787179
Instruction::Load, LoadTy, LI0->getPointerOperand(),
71797180
/*VariableMask=*/false, CommonAlignment, CostKind, LI0);

0 commit comments

Comments
 (0)