[Mlir-commits] [mlir] [mlir][scf]: Copy old attributes of old ForOp in replaceWithAdditionalYields (PR #95502)

Aviad Cohen llvmlistbot at llvm.org
Thu Jun 13 21:18:37 PDT 2024


https://github.com/AviadCo created https://github.com/llvm/llvm-project/pull/95502

…lYields

>From 752f287406cae7b8cf7584d3101807b47e68de15 Mon Sep 17 00:00:00 2001
From: Aviad Cohen <aviad.cohen2 at mobileye.com>
Date: Fri, 14 Jun 2024 07:15:13 +0300
Subject: [PATCH] [mlir][scf]: Copy old attributes of old ForOp in
 replaceWithAdditionalYields

---
 mlir/lib/Dialect/SCF/IR/SCF.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index 524711dbbb6fd..de3e5ef530e0c 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -588,8 +588,10 @@ ForOp::replaceWithAdditionalYields(RewriterBase &rewriter,
   }
 
   // Replace the old loop.
+  auto attrs = SmallVector<NamedAttribute, 4>(getOperation()->getAttrs());
   rewriter.replaceOp(getOperation(),
                      newLoop->getResults().take_front(getNumResults()));
+  newLoop->setAttrs(attrs);
   return cast<LoopLikeOpInterface>(newLoop.getOperation());
 }
 



More information about the Mlir-commits mailing list