[Mlir-commits] [mlir] [mlir][dataflow] Fix LivenessAnalysis/RemoveDeadValues handling of loop induction variables (PR #161117)

Mehdi Amini llvmlistbot at llvm.org
Mon Oct 20 08:00:12 PDT 2025


================
@@ -165,6 +165,28 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) {
           blocks.push_back(&block);
       }
     }
+
+    // In the block of the successor block argument of RegionBranchOpInterface,
+    // there may be arguments of RegionBranchOpInterface, such as the IV of
+    // scf.forOp. Explicitly set this argument to live.
+    auto regionBranchOp = cast<RegionBranchOpInterface>(op);
+    for (size_t i = 0, e = op->getNumRegions(); i < e; ++i) {
+      SmallVector<RegionSuccessor> successors;
+      regionBranchOp.getSuccessorRegions(op->getRegion(i), successors);
----------------
joker-eph wrote:

```suggestion
    for (Region &region : op->getRegions()) {
      SmallVector<RegionSuccessor> successors;
      regionBranchOp.getSuccessorRegions(&region, successors);
```

Nit: you don't need the loop counter, do you?

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


More information about the Mlir-commits mailing list