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

Mehdi Amini llvmlistbot at llvm.org
Tue Oct 21 03:00:18 PDT 2025


================
@@ -224,13 +244,20 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) {
     Liveness *operandLiveness = getLatticeElement(operand.get());
     LDBG() << "Marking branch operand live: " << operand.get();
     propagateIfChanged(operandLiveness, operandLiveness->markLive());
+    for (BlockArgument argument : argumentNotOperand) {
+      Liveness *argumentLiveness = getLatticeElement(argument);
+      LDBG() << "Marking RegionBranchOp's argument live: " << argument;
+      propagateIfChanged(argumentLiveness, argumentLiveness->markLive());
----------------
joker-eph wrote:

Do we agree that this is a conservative fix and in theory we should be able to remove %a in the example you posted above?
If so let's write a TODO:


```suggestion
      // TODO: this is overly conservative: we should be able to eliminate unused 
      // values in a RegionBranchOpInterface operation but that may requires removing
      // operation results which is beyond current capabilities of this pass right now.
      propagateIfChanged(argumentLiveness, argumentLiveness->markLive());
```

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


More information about the Mlir-commits mailing list