[Mlir-commits] [mlir] [rfc][mlir][gpu] Add operations to extract/insert/rotate within subgroup (PR #139048)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu May 8 06:19:45 PDT 2025


================
@@ -1364,6 +1364,35 @@ def GPU_ShuffleOp : GPU_Op<
   ];
 }
 
+def GPU_RotateOp : GPU_Op<
+    "rotate", [Pure, AllTypesMatch<["value", "rotateResult"]>]>,
+    Arguments<(ins AnyIntegerOrFloatOr1DVector:$value, I32:$offset, I32:$width)>,
+    Results<(outs AnyIntegerOrFloatOr1DVector:$rotateResult)> {
+  let summary = "Rotate values within a subgroup.";
+  let description = [{
+    The "rotate" op moves values to a across lanes circularly (a.k.a.,
+    invocations, work items) within the same subgroup. The `width` argument
+    specifies the number of lanes that participate in the rotation, and must
+    be uniform across all lanes. Further, the first `width` lanes of the
+    subgroup must be active.
+
+    Example:
+
+    ```mlir
+    %cst1 = arith.constant 1 : i32
+    %width = arith.constant 16 : i32
+    %1 = gpu.rotate %0, %cst1, %width : f32
+    ```
+
+    For lane 0 < `k` < 16, return the value from lane `(k - 1) % width`.
+    For lane k == 0, return the value from lane 15.
----------------
SoftwareBoi wrote:

```suggestion
    For lane `0 < k < 16`, return the value from lane `(k - 1) % width`.
    For lane `k == 0`, return the value from lane 15.
```

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


More information about the Mlir-commits mailing list