Skip to content

Commit

Permalink
[llvm] Use make_early_inc_range (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Nov 11, 2021
1 parent 5a4bd07 commit 642a361
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
15 changes: 4 additions & 11 deletions llvm/lib/CodeGen/ModuloSchedule.cpp
Expand Up @@ -332,14 +332,10 @@ static void replaceRegUsesAfterLoop(unsigned FromReg, unsigned ToReg,
MachineBasicBlock *MBB,
MachineRegisterInfo &MRI,
LiveIntervals &LIS) {
for (MachineRegisterInfo::use_iterator I = MRI.use_begin(FromReg),
E = MRI.use_end();
I != E;) {
MachineOperand &O = *I;
++I;
for (MachineOperand &O :
llvm::make_early_inc_range(MRI.use_operands(FromReg)))
if (O.getParent()->getParent() != MBB)
O.setReg(ToReg);
}
if (!LIS.hasInterval(ToReg))
LIS.createEmptyInterval(ToReg);
}
Expand Down Expand Up @@ -1137,12 +1133,9 @@ void ModuloScheduleExpander::rewriteScheduledInstr(
int StagePhi = Schedule.getStage(Phi) + PhiNum;
// Rewrite uses that have been scheduled already to use the new
// Phi register.
for (MachineRegisterInfo::use_iterator UI = MRI.use_begin(OldReg),
EI = MRI.use_end();
UI != EI;) {
MachineOperand &UseOp = *UI;
for (MachineOperand &UseOp :
llvm::make_early_inc_range(MRI.use_operands(OldReg))) {
MachineInstr *UseMI = UseOp.getParent();
++UI;
if (UseMI->getParent() != BB)
continue;
if (UseMI->isPHI()) {
Expand Down
8 changes: 2 additions & 6 deletions llvm/lib/CodeGen/RegisterCoalescer.cpp
Expand Up @@ -932,12 +932,8 @@ RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
// = B

// Update uses of IntA of the specific Val# with IntB.
for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(IntA.reg()),
UE = MRI->use_end();
UI != UE;
/* ++UI is below because of possible MI removal */) {
MachineOperand &UseMO = *UI;
++UI;
for (MachineOperand &UseMO :
llvm::make_early_inc_range(MRI->use_operands(IntA.reg()))) {
if (UseMO.isUndef())
continue;
MachineInstr *UseMI = UseMO.getParent();
Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/Target/Hexagon/HexagonOptimizeSZextends.cpp
Expand Up @@ -74,19 +74,16 @@ bool HexagonOptimizeSZextends::runOnFunction(Function &F) {
for (auto &Arg : F.args()) {
if (F.getAttributes().hasParamAttr(Idx, Attribute::SExt)) {
if (!isa<PointerType>(Arg.getType())) {
for (auto UI = Arg.use_begin(); UI != Arg.use_end();) {
if (isa<SExtInst>(*UI)) {
Instruction* Use = cast<Instruction>(*UI);
for (Use &U : llvm::make_early_inc_range(Arg.uses())) {
if (isa<SExtInst>(U)) {
Instruction* Use = cast<Instruction>(U);
SExtInst* SI = new SExtInst(&Arg, Use->getType());
assert (EVT::getEVT(SI->getType()) ==
(EVT::getEVT(Use->getType())));
++UI;
Use->replaceAllUsesWith(SI);
Instruction* First = &F.getEntryBlock().front();
SI->insertBefore(First);
Use->eraseFromParent();
} else {
++UI;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
Expand Up @@ -560,8 +560,8 @@ bool X86LowerAMXIntrinsics::lowerTileZero(Instruction *TileZero) {
IRBuilder<> Builder(TileZero);
FixedVectorType *V256I32Ty = FixedVectorType::get(Builder.getInt32Ty(), 256);
Value *VecZero = Constant::getNullValue(V256I32Ty);
for (auto UI = TileZero->use_begin(), UE = TileZero->use_end(); UI != UE;) {
Instruction *I = cast<Instruction>((UI++)->getUser());
for (Use &U : llvm::make_early_inc_range(TileZero->uses())) {
Instruction *I = cast<Instruction>(U.getUser());
Value *Vec;
if (match(I, m_BitCast(m_Value(Vec)))) {
I->replaceAllUsesWith(VecZero);
Expand Down

0 comments on commit 642a361

Please sign in to comment.