[flang-commits] [flang] [fir] Support promoting `fir.do_loop` with results to `affine.for`. (PR #137790)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu May 1 09:14:43 PDT 2025


================
@@ -461,14 +475,28 @@ class AffineLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
     LLVM_ATTRIBUTE_UNUSED auto loopAnalysis =
         functionAnalysis.getChildLoopAnalysis(loop);
     auto &loopOps = loop.getBody()->getOperations();
+    auto resultOp = cast<fir::ResultOp>(loop.getBody()->getTerminator());
----------------
tblah wrote:

Can a loop have multiple result operations if it contains multiple blocks inside the loop body?

As this is an experimental optimization I guess it would be okay to skip loops which are too complicated. But printing something in `LLVM_DEBUG(llvm::dbgs())` would be ideal.

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


More information about the flang-commits mailing list