aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
diff options
context:
space:
mode:
authorMogball <jeffniu22@gmail.com>2022-04-15 17:52:34 +0000
committerMogball <jeffniu22@gmail.com>2022-04-15 22:07:01 +0000
commit3131f808243abe3746280e016ab9459c14d9e53b (patch)
tree10470dc5ab5a10c1f9bdcf8bbc57be6a03f7050c /mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
parenta571f82a50416b767fd3cce0fb5027bb5dfec58c (diff)
downloadllvm-3131f808243abe3746280e016ab9459c14d9e53b.zip
llvm-3131f808243abe3746280e016ab9459c14d9e53b.tar.gz
llvm-3131f808243abe3746280e016ab9459c14d9e53b.tar.bz2
[mlir] Refactor LICM into a utility
LICM is refactored into a utility that is application on any region. The implementation is moved to Transform/Utils.
Diffstat (limited to 'mlir/lib/Transforms/LoopInvariantCodeMotion.cpp')
-rw-r--r--mlir/lib/Transforms/LoopInvariantCodeMotion.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
index 14761a8..35e0f48 100644
--- a/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
+++ b/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
@@ -11,15 +11,10 @@
//===----------------------------------------------------------------------===//
#include "PassDetail.h"
-#include "mlir/IR/Builders.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
-#include "mlir/Interfaces/SideEffectInterfaces.h"
+#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
#include "mlir/Transforms/Passes.h"
-#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Debug.h"
-
-#define DEBUG_TYPE "licm"
+#include "mlir/Transforms/SideEffectUtils.h"
using namespace mlir;
@@ -35,10 +30,8 @@ void LoopInvariantCodeMotion::runOnOperation() {
// Walk through all loops in a function in innermost-loop-first order. This
// way, we first LICM from the inner loop, and place the ops in
// the outer loop, which in turn can be further LICM'ed.
- getOperation()->walk([&](LoopLikeOpInterface loopLike) {
- LLVM_DEBUG(loopLike.print(llvm::dbgs() << "\nOriginal loop:\n"));
- moveLoopInvariantCode(loopLike);
- });
+ getOperation()->walk(
+ [&](LoopLikeOpInterface loopLike) { moveLoopInvariantCode(loopLike); });
}
std::unique_ptr<Pass> mlir::createLoopInvariantCodeMotionPass() {