[llvm] Populate SmallVector at construction time (NFC)

This commit is contained in:
Kazu Hirata 2021-01-28 22:21:14 -08:00
parent 046cfb8565
commit 7925aa091d
5 changed files with 5 additions and 16 deletions

View File

@ -2641,9 +2641,7 @@ std::tuple<bool, bool> InstrRefBasedLDV::vlocJoin(
auto &ILS = *ILSIt->second;
// Order predecessors by RPOT order, for exploring them in that order.
SmallVector<MachineBasicBlock *, 8> BlockOrders;
for (auto p : MBB.predecessors())
BlockOrders.push_back(p);
SmallVector<MachineBasicBlock *, 8> BlockOrders(MBB.predecessors());
auto Cmp = [&](MachineBasicBlock *A, MachineBasicBlock *B) {
return BBToOrder[A] < BBToOrder[B];

View File

@ -9749,9 +9749,7 @@ SDValue AArch64TargetLowering::LowerBUILD_VECTOR(SDValue Op,
if (PreferDUPAndInsert) {
// First, build a constant vector with the common element.
SmallVector<SDValue, 8> Ops;
for (unsigned I = 0; I < NumElts; ++I)
Ops.push_back(Value);
SmallVector<SDValue, 8> Ops(NumElts, Value);
SDValue NewVector = LowerBUILD_VECTOR(DAG.getBuildVector(VT, dl, Ops), DAG);
// Next, insert the elements that do not match the common value.
for (unsigned I = 0; I < NumElts; ++I)

View File

@ -110,12 +110,9 @@ void AMDGPUUnifyDivergentExitNodes::getAnalysisUsage(AnalysisUsage &AU) const{
/// XXX - Is there a more efficient way to find this?
static bool isUniformlyReached(const LegacyDivergenceAnalysis &DA,
BasicBlock &BB) {
SmallVector<BasicBlock *, 8> Stack;
SmallVector<BasicBlock *, 8> Stack(predecessors(&BB));
SmallPtrSet<BasicBlock *, 8> Visited;
for (BasicBlock *Pred : predecessors(&BB))
Stack.push_back(Pred);
while (!Stack.empty()) {
BasicBlock *Top = Stack.pop_back_val();
if (!DA.isUniform(Top->getTerminator()))

View File

@ -3550,9 +3550,7 @@ ARMTargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
/// Return true if all users of V are within function F, looking through
/// ConstantExprs.
static bool allUsersAreInFunction(const Value *V, const Function *F) {
SmallVector<const User*,4> Worklist;
for (auto *U : V->users())
Worklist.push_back(U);
SmallVector<const User*,4> Worklist(V->users());
while (!Worklist.empty()) {
auto *U = Worklist.pop_back_val();
if (isa<ConstantExpr>(U)) {

View File

@ -167,9 +167,7 @@ bool PPCLowerMASSVEntries::runOnModule(Module &M) {
// Call to lowerMASSVCall() invalidates the iterator over users upon
// replacing the users. Precomputing the current list of users allows us to
// replace all the call sites.
SmallVector<User *, 4> MASSVUsers;
for (auto *User: Func.users())
MASSVUsers.push_back(User);
SmallVector<User *, 4> MASSVUsers(Func.users());
for (auto *User : MASSVUsers) {
auto *CI = dyn_cast<CallInst>(User);