[Mlir-commits] [mlir] SparseAnalysis: support ReturnLike terminators (PR #140797)
donald chen
llvmlistbot at llvm.org
Wed May 21 06:59:07 PDT 2025
================
@@ -299,6 +330,28 @@ class SparseForwardDataFlowAnalysis
setAllToEntryStates(resultLattices);
}
+ /// Visit a region terminator. This is intended for non-control-flow
+ /// region-bearing ops whose terminators determine the lattice values of the
+ /// parent op's results. By default the terminator's operand lattices are
+ /// forwarded to the parent result lattices, if there is a 1-1
+ /// correspondence.
+ virtual LogicalResult visitNonControlFlowTerminator(
+ Operation *terminatorOp,
+ ArrayRef<const StateT *> terminatorOperandLattices,
+ ArrayRef<StateT *> parentResultLattices) {
+ // ReturnLike terminators forward their lattice values to the results of the
+ // parent op.
+ if (terminatorOp->hasTrait<OpTrait::ReturnLike>() &&
+ terminatorOperandLattices.size() == parentResultLattices.size()) {
+ for (const auto &[operandLattice, resultLattice] :
+ llvm::zip(terminatorOperandLattices, parentResultLattices)) {
+ propagateIfChanged(resultLattice, resultLattice->join(*operandLattice));
+ }
+ }
+
+ return success();
----------------
cxy-1993 wrote:
For example, linalg.generic do not have regionbranchopinterface, and linalg.yield have return trailt.
We should not propagate linalg.yield result's lattice to linalg.generic's result. Their datatype is even different.
https://github.com/llvm/llvm-project/pull/140797
More information about the Mlir-commits
mailing list