[Mlir-commits] [mlir] [mlir][rocdl] Add IR examples to OP definitions (PR #182147)
Krzysztof Drewniak
llvmlistbot at llvm.org
Wed Feb 18 17:13:13 PST 2026
================
@@ -270,6 +285,18 @@ class ROCDL_MbcntOp<string mnemonic> :
let assemblyFormat = [{
$in0 `,` $in1 attr-dict `:` `(` type($in0) `,` type($in1) `)` `->` type($res)
}];
+ let description = [{
+ Masked bit count of active threads in a wavefront.
+
+ Example:
+ ```mlir
+ // Count active threads in the low 32 lanes.
+ %lo = rocdl.mbcnt.lo %mask, %base : (i32, i32) -> i32
----------------
krzysz00 wrote:
Expand these out to the relevant constants, and point out that - if I remember right - in0 gets added to the counted bits.
That is, the operation for low is - unless I have the arguments backwards - `in0 + bitcount((in1 & ~((1 << min( lane ID, 32) ) - 1))` and the high variant is the same except it's saturating_usub(lane ID, 32)
https://github.com/llvm/llvm-project/pull/182147
More information about the Mlir-commits
mailing list