[Mlir-commits] [mlir] 5c77ed0 - [MLIR] NFC. gpu.launch op argument const folder cleanup

Uday Bondhugula llvmlistbot at llvm.org
Tue Sep 21 02:00:49 PDT 2021


Author: Uday Bondhugula
Date: 2021-09-21T14:30:03+05:30
New Revision: 5c77ed0330c47ad8fa4b229bceb6c33c76536961

URL: https://github.com/llvm/llvm-project/commit/5c77ed0330c47ad8fa4b229bceb6c33c76536961
DIFF: https://github.com/llvm/llvm-project/commit/5c77ed0330c47ad8fa4b229bceb6c33c76536961.diff

LOG: [MLIR] NFC. gpu.launch op argument const folder cleanup

NFC updates to gpu.launch op argument const folder.

Differential Revision: https://reviews.llvm.org/D110136

Added: 
    

Modified: 
    mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 26ab9551854a5..7c1bf8e654b81 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -532,23 +532,19 @@ static ParseResult parseLaunchOp(OpAsmParser &parser, OperationState &result) {
                  parser.parseOptionalAttrDict(result.attributes));
 }
 
-/// Simplify the gpu.launch when the range of the thread and block IDs is
+/// Simplify the gpu.launch when the range of a thread or block ID is
 /// trivially known to be one.
 struct FoldLaunchArguments : public OpRewritePattern<LaunchOp> {
   using OpRewritePattern<LaunchOp>::OpRewritePattern;
   LogicalResult matchAndRewrite(LaunchOp op,
                                 PatternRewriter &rewriter) const override {
-    auto isTriviallyOne = [](Value size) {
-      IntegerAttr cst;
-      return matchPattern(size, m_Constant(&cst)) && cst.getInt() == 1;
-    };
-
     // If the range implies a single value for `id`, replace `id`'s uses by
     // zero.
     Value zero;
     bool simplified = false;
     auto constPropIdUses = [&](Value id, Value size) {
-      if (!isTriviallyOne(size))
+      // Check if size is trivially one.
+      if (!matchPattern(size, m_One()))
         return;
       if (!simplified) {
         // Create a zero value the first time.


        


More information about the Mlir-commits mailing list