Skip to content

Commit

Permalink
[Transforms] Construct SmallVector with ArrayRef (NFC) (llvm#101851)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata authored and banach-space committed Aug 7, 2024
1 parent 1848d42 commit 89d0775
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 32 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/IPO/Attributor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ struct Attributor {
CalleeRepairCBTy &&CalleeRepairCB,
ACSRepairCBTy &&ACSRepairCB)
: A(A), ReplacedFn(*Arg.getParent()), ReplacedArg(Arg),
ReplacementTypes(ReplacementTypes.begin(), ReplacementTypes.end()),
ReplacementTypes(ReplacementTypes),
CalleeRepairCB(std::move(CalleeRepairCB)),
ACSRepairCB(std::move(ACSRepairCB)) {}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Coroutines/CoroSplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ struct SwitchCoroutineSplitter {
ArrayRef<Function *> Fns) {
// This only works under the switch-lowering ABI because coro elision
// only works on the switch-lowering ABI.
SmallVector<Constant *, 4> Args(Fns.begin(), Fns.end());
SmallVector<Constant *, 4> Args(Fns);
assert(!Args.empty());
Function *Part = *Fns.begin();
Module *M = Part->getParent();
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/Transforms/IPO/PartialInlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,10 @@ struct FunctionOutliningMultiRegionInfo {

// Container for outline regions
struct OutlineRegionInfo {
OutlineRegionInfo(ArrayRef<BasicBlock *> Region,
BasicBlock *EntryBlock, BasicBlock *ExitBlock,
BasicBlock *ReturnBlock)
: Region(Region.begin(), Region.end()), EntryBlock(EntryBlock),
ExitBlock(ExitBlock), ReturnBlock(ReturnBlock) {}
OutlineRegionInfo(ArrayRef<BasicBlock *> Region, BasicBlock *EntryBlock,
BasicBlock *ExitBlock, BasicBlock *ReturnBlock)
: Region(Region), EntryBlock(EntryBlock), ExitBlock(ExitBlock),
ReturnBlock(ReturnBlock) {}
SmallVector<BasicBlock *, 8> Region;
BasicBlock *EntryBlock;
BasicBlock *ExitBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ class CHRScope {

private:
CHRScope(ArrayRef<RegInfo> RegInfosIn, ArrayRef<CHRScope *> SubsIn)
: RegInfos(RegInfosIn.begin(), RegInfosIn.end()),
Subs(SubsIn.begin(), SubsIn.end()), BranchInsertPoint(nullptr) {}
: RegInfos(RegInfosIn), Subs(SubsIn), BranchInsertPoint(nullptr) {}
};

class CHR {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LoopInterchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ struct LoopInterchange {
}

bool run(LoopNest &LN) {
SmallVector<Loop *, 8> LoopList(LN.getLoops().begin(), LN.getLoops().end());
SmallVector<Loop *, 8> LoopList(LN.getLoops());
for (unsigned I = 1; I < LoopList.size(); ++I)
if (LoopList[I]->getParentLoop() != LoopList[I - 1])
return false;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ class LowerMatrixIntrinsics {
public:
MatrixTy() : IsColumnMajor(MatrixLayout == MatrixLayoutTy::ColumnMajor) {}
MatrixTy(ArrayRef<Value *> Vectors)
: Vectors(Vectors.begin(), Vectors.end()),
: Vectors(Vectors),
IsColumnMajor(MatrixLayout == MatrixLayoutTy::ColumnMajor) {}
MatrixTy(unsigned NumRows, unsigned NumColumns, Type *EltTy)
: IsColumnMajor(MatrixLayout == MatrixLayoutTy::ColumnMajor) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,7 @@ bool llvm::UnrollRuntimeLoopRemainder(
// (e.g. breakLoopBackedgeAndSimplify) and reused in loop-deletion.
BasicBlock *RemainderLatch = remainderLoop->getLoopLatch();
assert(RemainderLatch);
SmallVector<BasicBlock*> RemainderBlocks(remainderLoop->getBlocks().begin(),
remainderLoop->getBlocks().end());
SmallVector<BasicBlock *> RemainderBlocks(remainderLoop->getBlocks());
breakLoopBackedge(remainderLoop, *DT, *SE, *LI, nullptr);
remainderLoop = nullptr;

Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/Transforms/Utils/LoopVersioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ LoopVersioning::LoopVersioning(const LoopAccessInfo &LAI,
ArrayRef<RuntimePointerCheck> Checks, Loop *L,
LoopInfo *LI, DominatorTree *DT,
ScalarEvolution *SE)
: VersionedLoop(L), AliasChecks(Checks.begin(), Checks.end()),
Preds(LAI.getPSE().getPredicate()), LAI(LAI), LI(LI), DT(DT),
SE(SE) {
}
: VersionedLoop(L), AliasChecks(Checks), Preds(LAI.getPSE().getPredicate()),
LAI(LAI), LI(LI), DT(DT), SE(SE) {}

void LoopVersioning::versionLoop(
const SmallVectorImpl<Instruction *> &DefsUsedOutside) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8219,7 +8219,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,
// If not provably safe, use a select to form a safe divisor before widening the
// div/rem operation itself. Otherwise fall through to general handling below.
if (CM.isPredicatedInst(I)) {
SmallVector<VPValue *> Ops(Operands.begin(), Operands.end());
SmallVector<VPValue *> Ops(Operands);
VPValue *Mask = getBlockInMask(I->getParent());
VPValue *One =
Plan.getOrAddLiveIn(ConstantInt::get(I->getType(), 1u, false));
Expand Down
19 changes: 8 additions & 11 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ class BoUpSLP {
if (I1 && I2) {
if (I1->getParent() != I2->getParent())
return CheckSameEntryOrFail();
SmallVector<Value *, 4> Ops(MainAltOps.begin(), MainAltOps.end());
SmallVector<Value *, 4> Ops(MainAltOps);
Ops.push_back(I1);
Ops.push_back(I2);
InstructionsState S = getSameOpcode(Ops, TLI);
Expand Down Expand Up @@ -5236,7 +5236,7 @@ void BoUpSLP::reorderNodeWithReuses(TreeEntry &TE, ArrayRef<int> Mask) const {
TE.ReorderIndices.clear();
// Try to improve gathered nodes with clustered reuses, if possible.
ArrayRef<int> Slice = ArrayRef(NewMask).slice(0, Sz);
SmallVector<unsigned> NewOrder(Slice.begin(), Slice.end());
SmallVector<unsigned> NewOrder(Slice);
inversePermutation(NewOrder, NewMask);
reorderScalars(TE.Scalars, NewMask);
// Fill the reuses mask with the identity submasks.
Expand Down Expand Up @@ -7916,8 +7916,7 @@ class BaseShuffleAnalysis {
}
break;
}
SmallVector<int> ShuffleMask(SV->getShuffleMask().begin(),
SV->getShuffleMask().end());
SmallVector<int> ShuffleMask(SV->getShuffleMask());
combineMasks(LocalVF, ShuffleMask, Mask);
Mask.swap(ShuffleMask);
if (IsOp2Undef)
Expand Down Expand Up @@ -8017,15 +8016,13 @@ class BaseShuffleAnalysis {
isUndefVector(SV2->getOperand(1), UseMask2).all()) {
Op1 = SV1->getOperand(0);
Op2 = SV2->getOperand(0);
SmallVector<int> ShuffleMask1(SV1->getShuffleMask().begin(),
SV1->getShuffleMask().end());
SmallVector<int> ShuffleMask1(SV1->getShuffleMask());
int LocalVF = ShuffleMask1.size();
if (auto *FTy = dyn_cast<FixedVectorType>(Op1->getType()))
LocalVF = FTy->getNumElements();
combineMasks(LocalVF, ShuffleMask1, CombinedMask1);
CombinedMask1.swap(ShuffleMask1);
SmallVector<int> ShuffleMask2(SV2->getShuffleMask().begin(),
SV2->getShuffleMask().end());
SmallVector<int> ShuffleMask2(SV2->getShuffleMask());
LocalVF = ShuffleMask2.size();
if (auto *FTy = dyn_cast<FixedVectorType>(Op2->getType()))
LocalVF = FTy->getNumElements();
Expand Down Expand Up @@ -8062,7 +8059,7 @@ class BaseShuffleAnalysis {
if (isa<PoisonValue>(V1))
return Builder.createPoison(
cast<VectorType>(V1->getType())->getElementType(), Mask.size());
SmallVector<int> NewMask(Mask.begin(), Mask.end());
SmallVector<int> NewMask(Mask);
bool IsIdentity = peekThroughShuffles(V1, NewMask, /*SinglePermute=*/true);
assert(V1 && "Expected non-null value after looking through shuffles.");

Expand Down Expand Up @@ -8290,7 +8287,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
return TTI::TCC_Free;
auto *VecTy = getWidenedType(ScalarTy, VL.size());
InstructionCost GatherCost = 0;
SmallVector<Value *> Gathers(VL.begin(), VL.end());
SmallVector<Value *> Gathers(VL);
// Improve gather cost for gather of loads, if we can group some of the
// loads into vector loads.
InstructionsState S = getSameOpcode(VL, *R.TLI);
Expand Down Expand Up @@ -8725,7 +8722,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
const PointerUnion<Value *, const TreeEntry *> &P2,
ArrayRef<int> Mask) {
ShuffleCostBuilder Builder(TTI);
SmallVector<int> CommonMask(Mask.begin(), Mask.end());
SmallVector<int> CommonMask(Mask);
Value *V1 = P1.dyn_cast<Value *>(), *V2 = P2.dyn_cast<Value *>();
unsigned CommonVF = Mask.size();
InstructionCost ExtraCost = 0;
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Vectorize/VectorCombine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,15 +1434,15 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
M -= NumSrcElts;
};

SmallVector<int> NewMask0(OldMask.begin(), OldMask.end());
SmallVector<int> NewMask0(OldMask);
TargetTransformInfo::ShuffleKind SK0 = TargetTransformInfo::SK_PermuteTwoSrc;
if (X == Z) {
llvm::for_each(NewMask0, ConvertToUnary);
SK0 = TargetTransformInfo::SK_PermuteSingleSrc;
Z = PoisonValue::get(BinOpTy);
}

SmallVector<int> NewMask1(OldMask.begin(), OldMask.end());
SmallVector<int> NewMask1(OldMask);
TargetTransformInfo::ShuffleKind SK1 = TargetTransformInfo::SK_PermuteTwoSrc;
if (Y == W) {
llvm::for_each(NewMask1, ConvertToUnary);
Expand Down Expand Up @@ -1624,7 +1624,7 @@ bool VectorCombine::foldShuffleOfShuffles(Instruction &I) {
return false;

// Merge shuffles - replace index to the RHS poison arg with PoisonMaskElem,
SmallVector<int, 16> NewMask(OuterMask.begin(), OuterMask.end());
SmallVector<int, 16> NewMask(OuterMask);
for (int &M : NewMask) {
if (0 <= M && M < (int)NumImmElts) {
M = (InnerMask0[M] >= (int)NumSrcElts) ? PoisonMaskElem : InnerMask0[M];
Expand Down

0 comments on commit 89d0775

Please sign in to comment.