Skip to content

Commit 38c407b

Browse files
[mlir][SCF] Add single iteration scf.for promotion to the FuncOp level helper.
Previously only the Affine version would be folded. Differential Revision: https://reviews.llvm.org/D81261
1 parent 99d6e05 commit 38c407b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mlir/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,12 @@ LogicalResult mlir::promoteIfSingleIteration(scf::ForOp forOp) {
220220
/// their body into the containing Block.
221221
void mlir::promoteSingleIterationLoops(FuncOp f) {
222222
// Gathers all innermost loops through a post order pruned walk.
223-
f.walk([](AffineForOp forOp) { promoteIfSingleIteration(forOp); });
223+
f.walk([](Operation *op) {
224+
if (auto forOp = dyn_cast<AffineForOp>(op))
225+
promoteIfSingleIteration(forOp);
226+
else if (auto forOp = dyn_cast<scf::ForOp>(op))
227+
promoteIfSingleIteration(forOp);
228+
});
224229
}
225230

226231
/// Generates an affine.for op with the specified lower and upper bounds

0 commit comments

Comments
 (0)