MLIR 22.0.0git
AffineScalarReplacement.cpp
Go to the documentation of this file.
1//===- AffineScalarReplacement.cpp - Affine scalar replacement pass -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements a pass to forward affine memref stores to loads, thereby
10// potentially getting rid of intermediate memrefs entirely. It also removes
11// redundant loads.
12//===----------------------------------------------------------------------===//
13
15
19#include "mlir/IR/Dominance.h"
20
21namespace mlir {
22namespace affine {
23#define GEN_PASS_DEF_AFFINESCALARREPLACEMENT
24#include "mlir/Dialect/Affine/Passes.h.inc"
25} // namespace affine
26} // namespace mlir
27
28#define DEBUG_TYPE "affine-scalrep"
29
30using namespace mlir;
31using namespace mlir::affine;
32
33namespace {
34struct AffineScalarReplacement
36 AffineScalarReplacement> {
37 void runOnOperation() override;
38};
39
40} // namespace
41
42std::unique_ptr<OperationPass<func::FuncOp>>
44 return std::make_unique<AffineScalarReplacement>();
45}
46
47void AffineScalarReplacement::runOnOperation() {
48 affineScalarReplace(getOperation(), getAnalysis<DominanceInfo>(),
49 getAnalysis<PostDominanceInfo>(),
50 getAnalysis<AliasAnalysis>());
51}
std::unique_ptr< OperationPass< func::FuncOp > > createAffineScalarReplacementPass()
Creates a pass to replace affine memref accesses by scalars using store to load forwarding and redund...
Include the generated interface declarations.