[Mlir-commits] [mlir] [MLIR][GPU] Add a pattern to rewrite gpu.subgroup_id (PR #137671)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Apr 28 10:17:54 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- mlir/lib/Dialect/GPU/Transforms/SubgroupIdRewriter.cpp mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
index 86ad14682..7973ac64c 100644
--- a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
@@ -39,7 +39,8 @@ class FuncOp;
 /// Collect a set of patterns to rewrite GlobalIdOp op within the GPU dialect.
 void populateGpuGlobalIdPatterns(RewritePatternSet &patterns);
 
-/// Collect a set of patterns to rewrite SubgrouplIdOp op within the GPU dialect.
+/// Collect a set of patterns to rewrite SubgrouplIdOp op within the GPU
+/// dialect.
 void populateGpuSubgroupIdPatterns(RewritePatternSet &patterns);
 
 /// Collect a set of patterns to rewrite shuffle ops within the GPU dialect.
diff --git a/mlir/lib/Dialect/GPU/Transforms/SubgroupIdRewriter.cpp b/mlir/lib/Dialect/GPU/Transforms/SubgroupIdRewriter.cpp
index 2e1939b5c..1c322c101 100644
--- a/mlir/lib/Dialect/GPU/Transforms/SubgroupIdRewriter.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/SubgroupIdRewriter.cpp
@@ -25,9 +25,8 @@ namespace {
 struct GpuSubgroupIdRewriter final : OpRewritePattern<gpu::SubgroupIdOp> {
   using OpRewritePattern<gpu::SubgroupIdOp>::OpRewritePattern;
 
-  LogicalResult
-  matchAndRewrite(gpu::SubgroupIdOp op,
-                  PatternRewriter &rewriter) const override {
+  LogicalResult matchAndRewrite(gpu::SubgroupIdOp op,
+                                PatternRewriter &rewriter) const override {
     // Calculation of the thread's subgroup identifier.
     //
     // The process involves mapping the thread's 3D identifier within its
@@ -61,15 +60,12 @@ struct GpuSubgroupIdRewriter final : OpRewritePattern<gpu::SubgroupIdOp> {
     Value tidY = rewriter.create<gpu::ThreadIdOp>(loc, gpu::Dimension::y);
     Value tidZ = rewriter.create<gpu::ThreadIdOp>(loc, gpu::Dimension::z);
 
-    Value dimYxIdZ =
-        rewriter.create<index::MulOp>(loc, dimY, tidZ);
-    Value dimYxIdZPlusIdY =
-        rewriter.create<index::AddOp>(loc, dimYxIdZ, tidY);
+    Value dimYxIdZ = rewriter.create<index::MulOp>(loc, dimY, tidZ);
+    Value dimYxIdZPlusIdY = rewriter.create<index::AddOp>(loc, dimYxIdZ, tidY);
     Value dimYxIdZPlusIdYTimesDimX =
         rewriter.create<index::MulOp>(loc, dimX, dimYxIdZPlusIdY);
     Value IdXPlusDimYxIdZPlusIdYTimesDimX =
-        rewriter.create<index::AddOp>(loc, tidX,
-                                      dimYxIdZPlusIdYTimesDimX);
+        rewriter.create<index::AddOp>(loc, tidX, dimYxIdZPlusIdYTimesDimX);
     Value subgroupSize = rewriter.create<gpu::SubgroupSizeOp>(
         loc, rewriter.getIndexType(), /*upper_bound = */ nullptr);
     Value subgroupIdOp = rewriter.create<index::DivUOp>(

``````````

</details>


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


More information about the Mlir-commits mailing list