Files
clang-p2996/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
Michele Scuttari 2be8af8f0e [MLIR] Update pass declarations to new autogenerated files
The patch introduces the required changes to update the pass declarations and definitions to use the new autogenerated files and allow dropping the old infrastructure.

Reviewed By: mehdi_amini, rriddle

Differential Review: https://reviews.llvm.org/D132838
2022-08-30 21:56:31 +02:00

44 lines
1.5 KiB
C++

//===- LoopInvariantCodeMotion.cpp - Code to perform loop fusion-----------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements loop invariant code motion.
//
//===----------------------------------------------------------------------===//
#include "mlir/Transforms/Passes.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
#include "mlir/Transforms/SideEffectUtils.h"
namespace mlir {
#define GEN_PASS_DEF_LOOPINVARIANTCODEMOTIONPASS
#include "mlir/Transforms/Passes.h.inc"
} // namespace mlir
using namespace mlir;
namespace {
/// Loop invariant code motion (LICM) pass.
struct LoopInvariantCodeMotionPass
: public impl::LoopInvariantCodeMotionPassBase<
LoopInvariantCodeMotionPass> {
using LoopInvariantCodeMotionPassBase::LoopInvariantCodeMotionPassBase;
void runOnOperation() override;
};
} // namespace
void LoopInvariantCodeMotionPass::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) { moveLoopInvariantCode(loopLike); });
}