[Mlir-commits] [mlir] [mlir][LivenessAnalysis] Remove unnecessary addDependency on results (PR #179149)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Feb 1 15:23:01 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: None (neildhar)
<details>
<summary>Changes</summary>
The framework already calls `addDependency` through `getLatticeElementFor` before `visitOperation` is invoked with the lattices. We don't need to call it again here.
---
Full diff: https://github.com/llvm/llvm-project/pull/179149.diff
1 Files Affected:
- (modified) mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp (+12-16)
``````````diff
diff --git a/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp b/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp
index 4afc35d23fafa..7391f1d460c34 100644
--- a/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp
@@ -93,24 +93,20 @@ LivenessAnalysis::visitOperation(Operation *op, ArrayRef<Liveness *> operands,
}
// This marks values of type (3) liveness as "live".
- bool foundLiveResult = false;
for (const Liveness *r : results) {
- if (r->isLive && !foundLiveResult) {
- LDBG() << "[visitOperation] Found live result, "
- "meeting all operands with result: "
- << r;
- // It is assumed that each operand is used to compute each result of an
- // op. Thus, if at least one result is live, each operand is live.
- for (Liveness *operand : operands) {
- LDBG() << " [visitOperation] Meeting operand: " << operand
- << " with result: " << r;
- meet(operand, *r);
- }
- foundLiveResult = true;
+ if (!r->isLive)
+ continue;
+ LDBG() << "[visitOperation] Found live result, meeting all operands with "
+ "result: "
+ << r;
+ // It is assumed that each operand is used to compute each result of an op.
+ // Thus, if at least one result is live, each operand is live.
+ for (Liveness *operand : operands) {
+ LDBG() << " [visitOperation] Meeting operand: " << operand
+ << " with result: " << r;
+ meet(operand, *r);
}
- LDBG() << "[visitOperation] Adding dependency for result: " << r
- << " after op: " << OpWithFlags(op, OpPrintingFlags().skipRegions());
- addDependency(const_cast<Liveness *>(r), getProgramPointAfter(op));
+ break;
}
return success();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/179149
More information about the Mlir-commits
mailing list