From 5c77ed0330c47ad8fa4b229bceb6c33c76536961 Mon Sep 17 00:00:00 2001 From: Uday Bondhugula Date: Tue, 21 Sep 2021 14:23:22 +0530 Subject: [PATCH] [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 --- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index 26ab9551854a..7c1bf8e654b8 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 { using OpRewritePattern::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.