[Mlir-commits] [mlir] SparseAnalysis: support ReturnLike terminators (PR #140797)

donald chen llvmlistbot at llvm.org
Wed May 21 06:51:39 PDT 2025


================
@@ -235,6 +243,29 @@ class AbstractSparseForwardDataFlowAnalysis : public DataFlowAnalysis {
   /// Join the lattice element and propagate and update if it changed.
   void join(AbstractSparseLattice *lhs, const AbstractSparseLattice &rhs);
 
+  // Get the lattice elements of the operands.
+  SmallVector<const AbstractSparseLattice *> getOperandLattices(Operation *op) {
+    SmallVector<const AbstractSparseLattice *> operandLattices;
+    operandLattices.reserve(op->getNumOperands());
+    for (Value operand : op->getOperands()) {
+      AbstractSparseLattice *operandLattice = getLatticeElement(operand);
+      operandLattice->useDefSubscribe(this);
+      operandLattices.push_back(operandLattice);
+    }
+    return operandLattices;
+  }
+
+  // Get the lattice elements of the results.
+  SmallVector<AbstractSparseLattice *> getResultLattices(Operation *op) {
+    SmallVector<AbstractSparseLattice *> resultLattices;
+    resultLattices.reserve(op->getNumResults());
+    for (Value result : op->getResults()) {
+      AbstractSparseLattice *resultLattice = getLatticeElement(result);
+      resultLattices.push_back(resultLattice);
+    }
+    return resultLattices;
+  }
----------------
cxy-1993 wrote:

To propagate terminator op's result lattice to parent op's result, an 'RegionBranchOpInterface' should implemented on parent op. Implement this way is not acceptable to me.

Is there any reason you can not attach 'RegionBranchOpInterface' to parent operation?

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


More information about the Mlir-commits mailing list