[Mlir-commits] [mlir] [mlir] Fix RemoveDeadRegionBranchOpSuccessorInputs producing invalid scf.for (LoopLikeOpInterface tie) (PR #216627)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Aug 16 20:03:03 PDT 2026


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 origin/main HEAD --extensions h,cpp -- mlir/include/mlir/Interfaces/ControlFlowInterfaces.h mlir/lib/Dialect/SCF/IR/SCF.cpp mlir/lib/Interfaces/ControlFlowInterfaces.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
index 8657e50eb..b783dd564 100644
--- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
+++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
@@ -333,15 +333,15 @@ Region *getEnclosingRepetitiveRegion(Value value);
 /// Callback that reports pairs of successor-input values (e.g. a region
 /// iter_arg and its corresponding op result) that are structurally coupled and
 /// must be added or removed together, even if they are not linked through a
-/// shared successor operand in `getSuccessorOperandInputMapping`. This is needed
-/// when `getSuccessorRegions` refines the control-flow graph and drops an edge
-/// that would otherwise tie them (e.g. a statically-single-trip `scf.for` drops
-/// its region->region back edge, so its iter_args and results are no longer tied
-/// through the yield operand). Each reported pair is unioned into the set of
-/// tied successor inputs. Loop-like ops can implement this using
-/// `getRegionIterArgs()` / `getLoopResults()`.
-using RegionBranchStructuralTieFn =
-    std::function<void(Operation *, SmallVectorImpl<std::pair<Value, Value>> &)>;
+/// shared successor operand in `getSuccessorOperandInputMapping`. This is
+/// needed when `getSuccessorRegions` refines the control-flow graph and drops
+/// an edge that would otherwise tie them (e.g. a statically-single-trip
+/// `scf.for` drops its region->region back edge, so its iter_args and results
+/// are no longer tied through the yield operand). Each reported pair is unioned
+/// into the set of tied successor inputs. Loop-like ops can implement this
+/// using `getRegionIterArgs()` / `getLoopResults()`.
+using RegionBranchStructuralTieFn = std::function<void(
+    Operation *, SmallVectorImpl<std::pair<Value, Value>> &)>;
 
 /// Populate canonicalization patterns that simplify successor operands/inputs
 /// of region branch operations. Only operations with the given name are
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index 3b93f784e..9c54e9673 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -1011,8 +1011,9 @@ struct ForOpTensorCastFolder : public OpRewritePattern<ForOp> {
 /// not link them when `getSuccessorRegions` drops an edge for control-flow
 /// precision (e.g. a statically-single-trip `scf.for` drops its back edge), so
 /// report the coupling explicitly via `LoopLikeOpInterface`.
-static void addLoopLikeStructuralTies(
-    Operation *op, SmallVectorImpl<std::pair<Value, Value>> &ties) {
+static void
+addLoopLikeStructuralTies(Operation *op,
+                          SmallVectorImpl<std::pair<Value, Value>> &ties) {
   auto loopOp = dyn_cast<LoopLikeOpInterface>(op);
   if (!loopOp)
     return;

``````````

</details>


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


More information about the Mlir-commits mailing list