[llvm] [AMDGPU] Add DPP16 Row Share optimization for llvm.amdgcn.wave.shuffle (PR #177470)
Domenic Nutile via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 30 09:50:34 PST 2026
================
@@ -553,6 +553,93 @@ static CallInst *rewriteCall(IRBuilderBase &B, CallInst &Old,
return NewCall;
}
+// Return true for sequences of instructions that effectively assign
+// each lane to its thread ID
+static bool isThreadID(const GCNSubtarget &ST, Value *V) {
+ // Case 1:
+ // wave32: mbcnt_lo(-1, 0)
+ // wave64: mbcnt_hi(-1, mbcnt_lo(-1, 0))
+ auto W32Pred = m_Intrinsic<Intrinsic::amdgcn_mbcnt_lo>(m_ConstantInt<-1>(),
+ m_ConstantInt<0>());
+ auto W64Pred = m_Intrinsic<Intrinsic::amdgcn_mbcnt_hi>(
+ m_ConstantInt<-1>(), m_Intrinsic<Intrinsic::amdgcn_mbcnt_lo>(
+ m_ConstantInt<-1>(), m_ConstantInt<0>()));
+ if (ST.isWave32() && match(V, W32Pred))
+ return true;
+ if (ST.isWave64() && match(V, W64Pred))
+ return true;
+
+ // Case 2:
+ // workitem.x()
+ auto WIdXPred = m_Intrinsic<Intrinsic::amdgcn_workitem_id_x>();
----------------
saxlungs wrote:
Actually now that you mention it, doesn't this only work if workgroup x size is exactly equal to the wave size? If it's greater, then you could still get something out of bounds of the space of thread IDs right?
https://github.com/llvm/llvm-project/pull/177470
More information about the llvm-commits
mailing list