summaryrefslogtreecommitdiff
path: root/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp')
-rw-r--r--flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp b/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
index a233e7fbdcd1..1af5a68e8529 100644
--- a/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
+++ b/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp
@@ -132,10 +132,14 @@ public:
auto comparison = rewriter.create<mlir::arith::CmpIOp>(
loc, arith::CmpIPredicate::sgt, itersLeft, zero);
- rewriter.create<mlir::cf::CondBranchOp>(
+ auto cond = rewriter.create<mlir::cf::CondBranchOp>(
loc, comparison, firstBlock, llvm::ArrayRef<mlir::Value>(), endBlock,
llvm::ArrayRef<mlir::Value>());
+ // Copy loop annotations from the do loop to the loop entry condition.
+ if (auto ann = loop.getLoopAnnotation())
+ cond->setAttr("loop_annotation", *ann);
+
// The result of the loop operation is the values of the condition block
// arguments except the induction variable on the last iteration.
auto args = loop.getFinalValue()