[llvm] 69f5105 - [AMDGPU] Simplify insertNoops functions. NFC.
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 29 03:55:37 PDT 2020
Author: Jay Foad
Date: 2020-10-29T10:55:20Z
New Revision: 69f5105f5c009e1ca34d2c1f60ee4c78b8dfa543
URL: https://github.com/llvm/llvm-project/commit/69f5105f5c009e1ca34d2c1f60ee4c78b8dfa543
DIFF: https://github.com/llvm/llvm-project/commit/69f5105f5c009e1ca34d2c1f60ee4c78b8dfa543.diff
LOG: [AMDGPU] Simplify insertNoops functions. NFC.
Added:
Modified:
llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
index 59fca1617c22..e267df393c5e 100644
--- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -214,14 +214,10 @@ GCNHazardRecognizer::getHazardType(SUnit *SU, int Stalls) {
static void insertNoopsInBundle(MachineInstr *MI, const SIInstrInfo &TII,
unsigned Quantity) {
while (Quantity > 0) {
- unsigned Arg;
- if (Quantity >= 8)
- Arg = 7;
- else
- Arg = Quantity - 1;
- Quantity -= Arg + 1;
+ unsigned Arg = std::min(Quantity, 8u);
+ Quantity -= Arg;
BuildMI(*MI->getParent(), MI, MI->getDebugLoc(), TII.get(AMDGPU::S_NOP))
- .addImm(Arg);
+ .addImm(Arg - 1);
}
}
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 3d9a654f5c75..71a32821d23f 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -1543,13 +1543,9 @@ void SIInstrInfo::insertNoops(MachineBasicBlock &MBB,
unsigned Quantity) const {
DebugLoc DL = MBB.findDebugLoc(MI);
while (Quantity > 0) {
- unsigned Arg;
- if (Quantity >= 8)
- Arg = 7;
- else
- Arg = Quantity - 1;
- Quantity -= Arg + 1;
- BuildMI(MBB, MI, DL, get(AMDGPU::S_NOP)).addImm(Arg);
+ unsigned Arg = std::min(Quantity, 8u);
+ Quantity -= Arg;
+ BuildMI(MBB, MI, DL, get(AMDGPU::S_NOP)).addImm(Arg - 1);
}
}
More information about the llvm-commits
mailing list