[clang] [llvm] [SPIR-V] Add builtin/intrinsic for subgroup ballot (PR #174862)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 7 14:56:49 PST 2026


================
@@ -77,6 +77,8 @@ let TargetPrefix = "spv" in {
                           Intrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrWillReturn]>;
   def int_spv_subgroup_max_size : ClangBuiltin<"__builtin_spirv_subgroup_max_size">,
                           Intrinsic<[llvm_i32_ty], [], [NoUndef<RetIndex>, IntrNoMem, IntrWillReturn]>;
+  def int_spv_subgroup_ballot : ClangBuiltin<"__builtin_spirv_subgroup_ballot">,
+    DefaultAttrsIntrinsic<[llvm_v4i32_ty], [llvm_i1_ty], [IntrConvergent, IntrNoMem]>;
----------------
jhuber6 wrote:

>From the documentation
> Result Type must be a vector of four components of [integer type](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Integer) scalar, whose Width operand is 32 and whose Signedness operand is 0.
>
> Result is a set of bitfields where the first invocation is represented in the lowest bit of the first vector component and the last (up to the size of the [scope](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Scope)) is the higher bit number of the last bitmask needed to represent all bits of the invocations in the scope restricted tangle.

https://github.com/llvm/llvm-project/pull/174862


More information about the cfe-commits mailing list