MLIR  19.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"
21 #include <algorithm>
22 
23 namespace mlir {
24 namespace affine {
25 #define GEN_PASS_DEF_AFFINESCALARREPLACEMENT
26 #include "mlir/Dialect/Affine/Passes.h.inc"
27 } // namespace affine
28 } // namespace mlir
29 
30 #define DEBUG_TYPE "affine-scalrep"
31 
32 using namespace mlir;
33 using namespace mlir::affine;
34 
35 namespace {
36 struct AffineScalarReplacement
37  : public affine::impl::AffineScalarReplacementBase<
38  AffineScalarReplacement> {
39  void runOnOperation() override;
40 };
41 
42 } // namespace
43 
44 std::unique_ptr<OperationPass<func::FuncOp>>
46  return std::make_unique<AffineScalarReplacement>();
47 }
48 
49 void AffineScalarReplacement::runOnOperation() {
50  affineScalarReplace(getOperation(), getAnalysis<DominanceInfo>(),
51  getAnalysis<PostDominanceInfo>(),
52  getAnalysis<AliasAnalysis>());
53 }
std::unique_ptr< OperationPass< func::FuncOp > > createAffineScalarReplacementPass()
Creates a pass to replace affine memref accesses by scalars using store to load forwarding and redund...
void affineScalarReplace(func::FuncOp f, DominanceInfo &domInfo, PostDominanceInfo &postDomInfo, AliasAnalysis &analysis)
Replace affine store and load accesses by scalars by forwarding stores to loads and eliminate invaria...
Definition: Utils.cpp:1035
Include the generated interface declarations.