[llvm] [Target] Use llvm::replace (NFC) (PR #105942)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 24 08:19:08 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/105942
None
>From 08f820167440cd13b65d68a30dd9163322644109 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 24 Aug 2024 08:04:40 -0700
Subject: [PATCH] [Target] Use llvm::replace (NFC)
---
llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp | 4 +---
llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp | 5 +----
llvm/lib/Target/X86/X86ISelLowering.cpp | 4 +---
3 files changed, 3 insertions(+), 10 deletions(-)
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.
More information about the llvm-commits
mailing list