[Mlir-commits] [mlir] [mlir][spirv][gpu] Add lowering for `gpu.subgroup_broadcast` (PR #185818)

Igor Wodiany llvmlistbot at llvm.org
Wed Mar 11 02:00:49 PDT 2026


================
@@ -269,6 +269,55 @@ def SPIRV_GroupNonUniformBroadcastOp : SPIRV_Op<"GroupNonUniformBroadcast",
 
 // -----
 
+def SPIRV_GroupNonUniformBroadcastFirstOp : SPIRV_Op<"GroupNonUniformBroadcastFirst",
+  [Pure, AllTypesMatch<["value", "result"]>]> {
+  let summary = [{
+    Result is the Value of the invocation from the active invocations with 
+    the lowest id in the group to all active invocations in the group.
+  }];
+
+  let description = [{
+    Result Type  must be a scalar or vector of floating-point type, integer
+    type, or Boolean type.
+
+    Execution must be Workgroup or Subgroup Scope.
+
+    The type of Value must be the same as Result Type.
+
+    #### Example:
+
+    ```mlir
+    %scalar_value = ... : f32
+    %vector_value = ... : vector<4xf32>
+    %0 = spirv.GroupNonUniformBroadcastFirst <Subgroup> %scalar_value : f32
+    %1 = spirv.GroupNonUniformBroadcastFirst <Workgroup> %vector_value :
+      vector<4xf32>, i32 i32
+    ```
+  }];
+
+  let availability = [
+    MinVersion<SPIRV_V_1_3>,
+    MaxVersion<SPIRV_V_1_6>,
+    Extension<[]>,
+    Capability<[SPIRV_C_GroupNonUniformBallot]>
+  ];
+
+  let arguments = (ins
+    SPIRV_ScopeAttr:$execution_scope,
+    SPIRV_Type:$value
----------------
IgWod wrote:

Please constraint it so it only accepts "scalar or vector of [floating-point type](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Floating), [integer type](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Integer), or [Boolean type](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#Boolean)." See `GroupNonUniformQuadSwap` as an example. We should also add a negative test verifying that it fails for an incorrect type.

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


More information about the Mlir-commits mailing list