Skip to content

Commit 110d17b

Browse files
kazutakahirataIanWood1
authored andcommitted
[AMDGPU] Construct SmallVector with iterator ranges (NFC) (llvm#136415)
1 parent f52d466 commit 110d17b

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,11 +2261,10 @@ PtrParts SplitPtrStructs::visitIntrinsicInst(IntrinsicInst &I) {
22612261

22622262
void SplitPtrStructs::processFunction(Function &F) {
22632263
ST = &TM->getSubtarget<GCNSubtarget>(F);
2264-
SmallVector<Instruction *, 0> Originals;
2264+
SmallVector<Instruction *, 0> Originals(
2265+
llvm::make_pointer_range(instructions(F)));
22652266
LLVM_DEBUG(dbgs() << "Splitting pointer structs in function: " << F.getName()
22662267
<< "\n");
2267-
for (Instruction &I : instructions(F))
2268-
Originals.push_back(&I);
22692268
for (Instruction *I : Originals) {
22702269
auto [Rsrc, Off] = visit(I);
22712270
assert(((Rsrc && Off) || (!Rsrc && !Off)) &&

llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ Type *AMDGPURewriteOutArguments::getStoredType(Value &Arg) const {
114114
const int MaxUses = 10;
115115
int UseCount = 0;
116116

117-
SmallVector<Use *> Worklist;
118-
for (Use &U : Arg.uses())
119-
Worklist.push_back(&U);
117+
SmallVector<Use *> Worklist(llvm::make_pointer_range(Arg.uses()));
120118

121119
Type *StoredType = nullptr;
122120
while (!Worklist.empty()) {

llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,8 @@ bool GCNDPPCombine::combineDPPMov(MachineInstr &MovMI) const {
629629

630630
OrigMIs.push_back(&MovMI);
631631
bool Rollback = true;
632-
SmallVector<MachineOperand*, 16> Uses;
633-
634-
for (auto &Use : MRI->use_nodbg_operands(DPPMovReg)) {
635-
Uses.push_back(&Use);
636-
}
632+
SmallVector<MachineOperand *, 16> Uses(
633+
llvm::make_pointer_range(MRI->use_nodbg_operands(DPPMovReg)));
637634

638635
while (!Uses.empty()) {
639636
MachineOperand *Use = Uses.pop_back_val();

llvm/lib/Target/AMDGPU/SIFoldOperands.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -972,9 +972,8 @@ void SIFoldOperandsImpl::foldOperand(
972972
unsigned RegSeqDstSubReg = UseMI->getOperand(UseOpIdx + 1).getImm();
973973

974974
// Grab the use operands first
975-
SmallVector<MachineOperand *, 4> UsesToProcess;
976-
for (auto &Use : MRI->use_nodbg_operands(RegSeqDstReg))
977-
UsesToProcess.push_back(&Use);
975+
SmallVector<MachineOperand *, 4> UsesToProcess(
976+
llvm::make_pointer_range(MRI->use_nodbg_operands(RegSeqDstReg)));
978977
for (auto *RSUse : UsesToProcess) {
979978
MachineInstr *RSUseMI = RSUse->getParent();
980979

@@ -1552,9 +1551,8 @@ bool SIFoldOperandsImpl::foldInstOperand(MachineInstr &MI,
15521551
}
15531552
}
15541553

1555-
SmallVector<MachineOperand *, 4> UsesToProcess;
1556-
for (auto &Use : MRI->use_nodbg_operands(Dst.getReg()))
1557-
UsesToProcess.push_back(&Use);
1554+
SmallVector<MachineOperand *, 4> UsesToProcess(
1555+
llvm::make_pointer_range(MRI->use_nodbg_operands(Dst.getReg())));
15581556
for (auto *U : UsesToProcess) {
15591557
MachineInstr *UseMI = U->getParent();
15601558
foldOperand(OpToFold, UseMI, UseMI->getOperandNo(U), FoldList,
@@ -2380,10 +2378,9 @@ bool SIFoldOperandsImpl::tryFoldLoad(MachineInstr &MI) {
23802378
if (DefReg.isPhysical() || !TRI->isVGPR(*MRI, DefReg))
23812379
return false;
23822380

2383-
SmallVector<const MachineInstr*, 8> Users;
2381+
SmallVector<const MachineInstr *, 8> Users(
2382+
llvm::make_pointer_range(MRI->use_nodbg_instructions(DefReg)));
23842383
SmallVector<Register, 8> MoveRegs;
2385-
for (const MachineInstr &I : MRI->use_nodbg_instructions(DefReg))
2386-
Users.push_back(&I);
23872384

23882385
if (Users.empty())
23892386
return false;

0 commit comments

Comments
 (0)