[llvm] ab2e27f - [AMDGPU] Small cleanup in insertWaitcntInBlock()
Stephen Thomas via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 03:59:13 PST 2022
Author: Stephen Thomas
Date: 2022-12-07T11:58:59Z
New Revision: ab2e27faa4cb9b7b63bf043ed329acbcaff7959c
URL: https://github.com/llvm/llvm-project/commit/ab2e27faa4cb9b7b63bf043ed329acbcaff7959c
DIFF: https://github.com/llvm/llvm-project/commit/ab2e27faa4cb9b7b63bf043ed329acbcaff7959c.diff
LOG: [AMDGPU] Small cleanup in insertWaitcntInBlock()
Move some code that checks if an instruction is a waitcount into a separate
function, mainly to aid readability in the logic where it is used.
Differential Revision: https://reviews.llvm.org/D139522
Added:
Modified:
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
index 3a7e017b0945..c596603d7b5a 100644
--- a/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1528,6 +1528,13 @@ bool WaitcntBrackets::merge(const WaitcntBrackets &Other) {
return StrictDom;
}
+static bool isWaitInstr(MachineInstr &Inst) {
+ return Inst.getOpcode() == AMDGPU::S_WAITCNT ||
+ (Inst.getOpcode() == AMDGPU::S_WAITCNT_VSCNT &&
+ Inst.getOperand(0).isReg() &&
+ Inst.getOperand(0).getReg() == AMDGPU::SGPR_NULL);
+}
+
// Generate s_waitcnt instructions where needed.
bool SIInsertWaitcnts::insertWaitcntInBlock(MachineFunction &MF,
MachineBasicBlock &Block,
@@ -1563,10 +1570,7 @@ bool SIInsertWaitcnts::insertWaitcntInBlock(MachineFunction &MF,
// Track pre-existing waitcnts that were added in earlier iterations or by
// the memory legalizer.
- if (Inst.getOpcode() == AMDGPU::S_WAITCNT ||
- (Inst.getOpcode() == AMDGPU::S_WAITCNT_VSCNT &&
- Inst.getOperand(0).isReg() &&
- Inst.getOperand(0).getReg() == AMDGPU::SGPR_NULL)) {
+ if (isWaitInstr(Inst)) {
if (!OldWaitcntInstr)
OldWaitcntInstr = &Inst;
++Iter;
More information about the llvm-commits
mailing list