MLIR  14.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 // TODO: In the future, similar techniques could be used to eliminate
13 // dead memref store's and perform more complex forwarding when support for
14 // SSA scalars live out of 'affine.for'/'affine.if' statements is available.
15 //===----------------------------------------------------------------------===//
16 
18 
19 #include "PassDetail.h"
21 #include "mlir/IR/Dominance.h"
23 #include <algorithm>
24 
25 #define DEBUG_TYPE "affine-scalrep"
26 
27 using namespace mlir;
28 
29 namespace {
30 struct AffineScalarReplacement
31  : public AffineScalarReplacementBase<AffineScalarReplacement> {
32  void runOnOperation() override;
33 };
34 
35 } // namespace
36 
37 std::unique_ptr<OperationPass<FuncOp>>
39  return std::make_unique<AffineScalarReplacement>();
40 }
41 
42 void AffineScalarReplacement::runOnOperation() {
43  affineScalarReplace(getOperation(), getAnalysis<DominanceInfo>(),
44  getAnalysis<PostDominanceInfo>());
45 }
Include the generated interface declarations.
void affineScalarReplace(FuncOp f, DominanceInfo &domInfo, PostDominanceInfo &postDomInfo)
Replace affine store and load accesses by scalars by forwarding stores to loads and eliminate invaria...
Definition: Utils.cpp:809
std::unique_ptr< OperationPass< FuncOp > > createAffineScalarReplacementPass()
Creates a pass to replace affine memref accesses by scalars using store to load forwarding and redund...