[Mlir-commits] [mlir] [MLIR][SCF] Fix LoopPeelOp documentation (NFC) (PR #113179)
Hugo Trachino
llvmlistbot at llvm.org
Mon Oct 28 03:02:48 PDT 2024
https://github.com/nujaa updated https://github.com/llvm/llvm-project/pull/113179
>From 25e0b03e421b01bf1c0cc515e25e59fdb490374a Mon Sep 17 00:00:00 2001
From: Hugo <hugo.trachino at huawei.com>
Date: Fri, 18 Oct 2024 16:41:20 +0800
Subject: [PATCH 1/3] [MLIR][SCF] Fix LoopPeelOp documentation (NFC)
---
.../mlir/Dialect/SCF/TransformOps/SCFTransformOps.td | 12 ++++++------
.../Dialect/SCF/Transforms/LoopSpecialization.cpp | 11 +++++------
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td b/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
index 20880d94a83cac..d13c1ba9a8ed1e 100644
--- a/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
+++ b/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
@@ -146,7 +146,7 @@ def LoopPeelOp : Op<Transform_Dialect, "loop.peel",
let summary = "Peels the first or last iteration of the loop";
let description = [{
Rewrite the given loop with a main loop and a partial (first or last) loop.
- When the `peelFront` option is set as true, the first iteration is peeled off.
+ When the `peelFront` option is set to true, the first iteration is peeled off.
Otherwise, updates the given loop so that its step evenly divides its range and puts
the remaining iteration into a separate loop or a conditional.
@@ -158,12 +158,12 @@ def LoopPeelOp : Op<Transform_Dialect, "loop.peel",
This operation ignores non-scf::ForOp ops and drops them in the return.
When `peelFront` is true, this operation returns two scf::ForOp Ops, the
- first scf::ForOp corresponds to the first iteration of the loop which can
- be canonicalized away in the following optimization. The second loop Op
- contains the remaining iteration, and the new lower bound is the original
- lower bound plus the number of steps.
+ first scf::ForOp corresponds to the target loop, whose lower bound has
+ been updated to the original lower bound plus the step. The second result
+ is the first iteration of the loop which can be canonicalized away in the
+ following optimization.
- When `peelFront` is not true, this operation returns two scf::ForOp Ops, with the first
+ When `peelFront` is false, this operation returns two scf::ForOp Ops, with the first
scf::ForOp satisfying: "the loop trip count is divisible by the step".
The second loop Op contains the remaining iteration. Note that even though the
Payload IR modification may be performed in-place, this operation consumes
diff --git a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
index a30e349d49136c..c06a448c3108c3 100644
--- a/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/LoopSpecialization.cpp
@@ -206,12 +206,11 @@ LogicalResult mlir::scf::peelForLoopAndSimplifyBounds(RewriterBase &rewriter,
return success();
}
-/// When the `peelFront` option is set as true, the first iteration of the loop
-/// is peeled off. This function rewrites the original scf::ForOp as two
-/// scf::ForOp Ops, the first scf::ForOp corresponds to the first iteration of
-/// the loop which can be canonicalized away in the following optimization. The
-/// second loop Op contains the remaining iteration, and the new lower bound is
-/// the original lower bound plus the number of steps.
+/// Rewrites the original scf::ForOp as two scf::ForOp Ops, the first scf::ForOp
+/// corresponds to the first iteration of the loop which can be canonicalized
+/// away in the following optimization. The second loop Op contains the
+/// remaining iteration, and the new lower bound is the original lower bound
+/// plus the number of steps.
LogicalResult mlir::scf::peelForLoopFirstIteration(RewriterBase &b, ForOp forOp,
ForOp &firstIteration) {
RewriterBase::InsertionGuard guard(b);
>From 8bf6967302798eeb3b0b808d76d1b89d48cab791 Mon Sep 17 00:00:00 2001
From: Hugo <hugo.trachino at huawei.com>
Date: Fri, 25 Oct 2024 19:13:13 +0800
Subject: [PATCH 2/3] fixup! [MLIR][SCF] Fix LoopPeelOp documentation (NFC)
---
.../SCF/TransformOps/SCFTransformOps.td | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td b/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
index d13c1ba9a8ed1e..6381168256d129 100644
--- a/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
+++ b/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
@@ -156,18 +156,18 @@ def LoopPeelOp : Op<Transform_Dialect, "loop.peel",
#### Return modes
This operation ignores non-scf::ForOp ops and drops them in the return.
-
- When `peelFront` is true, this operation returns two scf::ForOp Ops, the
- first scf::ForOp corresponds to the target loop, whose lower bound has
- been updated to the original lower bound plus the step. The second result
- is the first iteration of the loop which can be canonicalized away in the
- following optimization.
-
- When `peelFront` is false, this operation returns two scf::ForOp Ops, with the first
- scf::ForOp satisfying: "the loop trip count is divisible by the step".
- The second loop Op contains the remaining iteration. Note that even though the
- Payload IR modification may be performed in-place, this operation consumes
- the operand handle and produces a new one.
+ The op returns two loops, the peeled loop and the remainder loop.
+
+ When `peelFront` is true, the first scf::ForOp (the remainder loop)
+ executes all iterations of the target loop but the first one. The second
+ scf::ForOp corresponds to the first iteration of the loop which can be
+ canonicalized away in the following optimizations (the peeled loop).
+
+ When `peelFront` is false, the first result (the main loop) is "the loop
+ with the highest upper bound that is divisible by the step". The second
+ loopOp (remainder loop) contains the remaining iterations. Note that even
+ though the Payload IR modification may be performed in-place, this
+ operation consumes the operand handle and produces a new one.
#### Return Modes
>From 507cee20d7c1851a792cee330c0f26600d465838 Mon Sep 17 00:00:00 2001
From: Hugo Trachino <hugo.trachino at huawei.com>
Date: Mon, 28 Oct 2024 10:02:35 +0000
Subject: [PATCH 3/3] imporove consistency in naming
---
.../include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td b/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
index 6381168256d129..0ac6615c6768e8 100644
--- a/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
+++ b/mlir/include/mlir/Dialect/SCF/TransformOps/SCFTransformOps.td
@@ -156,14 +156,15 @@ def LoopPeelOp : Op<Transform_Dialect, "loop.peel",
#### Return modes
This operation ignores non-scf::ForOp ops and drops them in the return.
- The op returns two loops, the peeled loop and the remainder loop.
+ The op returns two loops, the peeled loop whose tripcount is divisible by
+ the step and the remainder loop.
When `peelFront` is true, the first scf::ForOp (the remainder loop)
executes all iterations of the target loop but the first one. The second
scf::ForOp corresponds to the first iteration of the loop which can be
canonicalized away in the following optimizations (the peeled loop).
- When `peelFront` is false, the first result (the main loop) is "the loop
+ When `peelFront` is false, the first result (peeled loop) is "the loop
with the highest upper bound that is divisible by the step". The second
loopOp (remainder loop) contains the remaining iterations. Note that even
though the Payload IR modification may be performed in-place, this
More information about the Mlir-commits
mailing list