[llvm] [AMDGPU] Add DPP16 Row Share optimization for llvm.amdgcn.wave.shuffle (PR #177470)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 30 01:46: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>();
----------------
jayfoad wrote:
This only works if the workgroup x size is >= the wave size.
https://github.com/llvm/llvm-project/pull/177470
More information about the llvm-commits
mailing list