[llvm] efc7bf2 - [AMDGPU] SIFoldOperands: use MachineRegisterInfo::hasOneNonDBGUser
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 6 07:24:13 PDT 2021
Author: Jay Foad
Date: 2021-04-06T15:23:58+01:00
New Revision: efc7bf27f5ee87ac106c6e48c4276e26f4f04715
URL: https://github.com/llvm/llvm-project/commit/efc7bf27f5ee87ac106c6e48c4276e26f4f04715
DIFF: https://github.com/llvm/llvm-project/commit/efc7bf27f5ee87ac106c6e48c4276e26f4f04715.diff
LOG: [AMDGPU] SIFoldOperands: use MachineRegisterInfo::hasOneNonDBGUser
NFC.
Added:
Modified:
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index 4da04ce2baa7..3857d3ebaa96 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1353,23 +1353,10 @@ const MachineOperand *SIFoldOperands::isClamp(const MachineInstr &MI) const {
}
}
-// We obviously have multiple uses in a clamp since the register is used twice
-// in the same instruction.
-static bool hasOneNonDBGUseInst(const MachineRegisterInfo &MRI, unsigned Reg) {
- int Count = 0;
- for (auto I = MRI.use_instr_nodbg_begin(Reg), E = MRI.use_instr_nodbg_end();
- I != E; ++I) {
- if (++Count > 1)
- return false;
- }
-
- return true;
-}
-
// FIXME: Clamp for v_mad_mixhi_f16 handled during isel.
bool SIFoldOperands::tryFoldClamp(MachineInstr &MI) {
const MachineOperand *ClampSrc = isClamp(MI);
- if (!ClampSrc || !hasOneNonDBGUseInst(*MRI, ClampSrc->getReg()))
+ if (!ClampSrc || !MRI->hasOneNonDBGUser(ClampSrc->getReg()))
return false;
MachineInstr *Def = MRI->getVRegDef(ClampSrc->getReg());
@@ -1509,7 +1496,7 @@ bool SIFoldOperands::tryFoldOMod(MachineInstr &MI) {
std::tie(RegOp, OMod) = isOMod(MI);
if (OMod == SIOutMods::NONE || !RegOp->isReg() ||
RegOp->getSubReg() != AMDGPU::NoSubRegister ||
- !hasOneNonDBGUseInst(*MRI, RegOp->getReg()))
+ !MRI->hasOneNonDBGUser(RegOp->getReg()))
return false;
MachineInstr *Def = MRI->getVRegDef(RegOp->getReg());
More information about the llvm-commits
mailing list