[Mlir-commits] [mlir] [mlir][sparse] Lower affine before SCF to CF in sparsifier (PR #219860)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Aug 30 16:47:35 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-sparse
Author: Kohei Yamaguchi (sott0n)
<details>
<summary>Changes</summary>
Fix the lowering order in the sparsifier pipeline by running `convert-scf-to-cf` after `lower-affine`.
Previously, `convert-scf-to-cf` ran while Affine control-flow operations could still be present. For example, lowering an `scf.if` nested inside an `affine.for` introduces multiple blocks into the loop body, violating `affine.for`'s single-block region requirement and causing verification to fail.
Running `lower-affine` first converts Affine control flow to SCF. The subsequent `convert-scf-to-cf` pass can then lower both the existing SCF operations and those introduced by Affine lowering to CFG-based control flow.
`expand-strided-metadata` remains before `lower-affine`, since it can introduce Affine operations.
Fixes #<!-- -->217895.
---
Full diff: https://github.com/llvm/llvm-project/pull/219860.diff
1 Files Affected:
- (modified) mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp (+1-1)
``````````diff
diff --git a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
index d85966ec88f98..9e33544efbcce 100644
--- a/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Pipelines/SparseTensorPipelines.cpp
@@ -67,9 +67,9 @@ void mlir::sparse_tensor::buildSparsifier(OpPassManager &pm,
pm.addNestedPass<func::FuncOp>(createConvertLinalgToLoopsPass());
pm.addNestedPass<func::FuncOp>(createConvertVectorToSCFPass());
pm.addNestedPass<func::FuncOp>(memref::createExpandReallocPass());
- pm.addNestedPass<func::FuncOp>(createSCFToControlFlowPass());
pm.addPass(memref::createExpandStridedMetadataPass());
pm.addPass(createLowerAffinePass());
+ pm.addNestedPass<func::FuncOp>(createSCFToControlFlowPass());
pm.addPass(
createConvertVectorToLLVMPass(options.convertVectorToLLVMOptions()));
pm.addNestedPass<func::FuncOp>(createConvertComplexToStandardPass());
``````````
</details>
https://github.com/llvm/llvm-project/pull/219860
More information about the Mlir-commits
mailing list