[Mlir-commits] [mlir] [mlir][gpu] Add gpu.rotate operation (PR #142796)

Hsiangkai Wang llvmlistbot at llvm.org
Wed Jun 18 13:31:41 PDT 2025


================
@@ -1364,6 +1364,49 @@ 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 across lanes (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.
+
+    `width` must be a power of two, and `offset` must be in the range
+    `[0, width)`.
+
+    Return the `rotateResult` of the invocation whose id within the group is
+    calculated as follows:
+
+    Invocation ID = ((LocalId + Delta) & (width - 1)) + (LocalId & ~(width - 1))
+
+    Returns the `rotateResult` if the current lane id is smaller than `width`.
+
+    example:
+
+    ```mlir
+    %cst1 = arith.constant 1 : i32
----------------
Hsiangkai wrote:

Updated.

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


More information about the Mlir-commits mailing list