@@ -63,7 +63,7 @@ namespace {
63
63
struct MemRefDataFlowOpt : public MemRefDataFlowOptBase <MemRefDataFlowOpt> {
64
64
void runOnFunction () override ;
65
65
66
- void forwardStoreToLoad (AffineLoadOp loadOp);
66
+ void forwardStoreToLoad (AffineReadOpInterface loadOp);
67
67
68
68
// A list of memref's that are potentially dead / could be eliminated.
69
69
SmallPtrSet<Value, 4 > memrefsToErase;
@@ -84,14 +84,14 @@ std::unique_ptr<OperationPass<FuncOp>> mlir::createMemRefDataFlowOptPass() {
84
84
85
85
// This is a straightforward implementation not optimized for speed. Optimize
86
86
// if needed.
87
- void MemRefDataFlowOpt::forwardStoreToLoad (AffineLoadOp loadOp) {
87
+ void MemRefDataFlowOpt::forwardStoreToLoad (AffineReadOpInterface loadOp) {
88
88
// First pass over the use list to get the minimum number of surrounding
89
89
// loops common between the load op and the store op, with min taken across
90
90
// all store ops.
91
91
SmallVector<Operation *, 8 > storeOps;
92
92
unsigned minSurroundingLoops = getNestingDepth (loadOp);
93
93
for (auto *user : loadOp.getMemRef ().getUsers ()) {
94
- auto storeOp = dyn_cast<AffineStoreOp >(user);
94
+ auto storeOp = dyn_cast<AffineWriteOpInterface >(user);
95
95
if (!storeOp)
96
96
continue ;
97
97
unsigned nsLoops = getNumCommonSurroundingLoops (*loadOp, *storeOp);
@@ -167,8 +167,9 @@ void MemRefDataFlowOpt::forwardStoreToLoad(AffineLoadOp loadOp) {
167
167
return ;
168
168
169
169
// Perform the actual store to load forwarding.
170
- Value storeVal = cast<AffineStoreOp>(lastWriteStoreOp).getValueToStore ();
171
- loadOp.replaceAllUsesWith (storeVal);
170
+ Value storeVal =
171
+ cast<AffineWriteOpInterface>(lastWriteStoreOp).getValueToStore ();
172
+ loadOp.getValue ().replaceAllUsesWith (storeVal);
172
173
// Record the memref for a later sweep to optimize away.
173
174
memrefsToErase.insert (loadOp.getMemRef ());
174
175
// Record this to erase later.
@@ -190,7 +191,7 @@ void MemRefDataFlowOpt::runOnFunction() {
190
191
memrefsToErase.clear ();
191
192
192
193
// Walk all load's and perform store to load forwarding.
193
- f.walk ([&](AffineLoadOp loadOp) { forwardStoreToLoad (loadOp); });
194
+ f.walk ([&](AffineReadOpInterface loadOp) { forwardStoreToLoad (loadOp); });
194
195
195
196
// Erase all load op's whose results were replaced with store fwd'ed ones.
196
197
for (auto *loadOp : loadOpsToErase)
@@ -207,7 +208,7 @@ void MemRefDataFlowOpt::runOnFunction() {
207
208
// could still erase it if the call had no side-effects.
208
209
continue ;
209
210
if (llvm::any_of (memref.getUsers (), [&](Operation *ownerOp) {
210
- return !isa<AffineStoreOp , DeallocOp>(ownerOp);
211
+ return !isa<AffineWriteOpInterface , DeallocOp>(ownerOp);
211
212
}))
212
213
continue ;
213
214
0 commit comments