-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Target] Use llvm::replace (NFC) #105942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Target] Use llvm::replace (NFC) #105942
Conversation
@llvm/pr-subscribers-backend-hexagon @llvm/pr-subscribers-backend-arm Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/105942.diff 3 Files Affected:
diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
index b55b9a42e52cdf..e42623cb385637 100644
--- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
@@ -2517,9 +2517,7 @@ static void updateRegisterMapForDbgValueListAfterMove(
if (RegIt == RegisterMap.end())
return;
auto &InstrVec = RegIt->getSecond();
- for (unsigned I = 0; I < InstrVec.size(); I++)
- if (InstrVec[I] == InstrToReplace)
- InstrVec[I] = DbgValueListInstr;
+ llvm::replace(InstrVec, InstrToReplace, DbgValueListInstr);
});
}
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index ec5435949ae4a7..4e6b80284c46b3 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -2002,10 +2002,7 @@ SmallVector<uint32_t, 8> HvxSelector::getPerfectCompletions(ShuffleMask SM,
if ((unsigned)llvm::popcount(P) < Count) {
// Reset all occurences of P, if there are more occurrences of P
// than there are bits in P.
- for (unsigned &Q : Worklist) {
- if (Q == P)
- Q = 0;
- }
+ llvm::replace(Worklist, P, 0U);
}
}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 97775ce40aee4f..1a6be4eb5af1ef 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -35781,9 +35781,7 @@ X86TargetLowering::EmitLoweredIndirectThunk(MachineInstr &MI,
// Zero out any registers that are already used.
for (const auto &MO : MI.operands()) {
if (MO.isReg() && MO.isUse())
- for (unsigned &Reg : AvailableRegs)
- if (Reg == MO.getReg())
- Reg = 0;
+ llvm::replace(AvailableRegs, static_cast<unsigned>(MO.getReg()), 0U);
}
// Choose the first remaining non-zero available register.
|
@llvm/pr-subscribers-backend-x86 Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/105942.diff 3 Files Affected:
diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
index b55b9a42e52cdf..e42623cb385637 100644
--- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
@@ -2517,9 +2517,7 @@ static void updateRegisterMapForDbgValueListAfterMove(
if (RegIt == RegisterMap.end())
return;
auto &InstrVec = RegIt->getSecond();
- for (unsigned I = 0; I < InstrVec.size(); I++)
- if (InstrVec[I] == InstrToReplace)
- InstrVec[I] = DbgValueListInstr;
+ llvm::replace(InstrVec, InstrToReplace, DbgValueListInstr);
});
}
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index ec5435949ae4a7..4e6b80284c46b3 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -2002,10 +2002,7 @@ SmallVector<uint32_t, 8> HvxSelector::getPerfectCompletions(ShuffleMask SM,
if ((unsigned)llvm::popcount(P) < Count) {
// Reset all occurences of P, if there are more occurrences of P
// than there are bits in P.
- for (unsigned &Q : Worklist) {
- if (Q == P)
- Q = 0;
- }
+ llvm::replace(Worklist, P, 0U);
}
}
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 97775ce40aee4f..1a6be4eb5af1ef 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -35781,9 +35781,7 @@ X86TargetLowering::EmitLoweredIndirectThunk(MachineInstr &MI,
// Zero out any registers that are already used.
for (const auto &MO : MI.operands()) {
if (MO.isReg() && MO.isUse())
- for (unsigned &Reg : AvailableRegs)
- if (Reg == MO.getReg())
- Reg = 0;
+ llvm::replace(AvailableRegs, static_cast<unsigned>(MO.getReg()), 0U);
}
// Choose the first remaining non-zero available register.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers
No description provided.