[Mlir-commits] [mlir] SparseAnalysis: support ReturnLike terminators (PR #140797)
Jeremy Kun
llvmlistbot at llvm.org
Wed May 21 10:26:51 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;
+ }
----------------
j2kun wrote:
I think this is what I will end up doing instead of this PR (cf. https://discourse.llvm.org/t/how-should-non-control-flow-region-bearing-ops-be-used-with-by-dataflow-analyses/86438/2). But at the time I wrote this PR I was unsure how to do this properly because my op does not have branching behavior.
https://github.com/llvm/llvm-project/pull/140797
More information about the Mlir-commits
mailing list