@@ -63,7 +63,7 @@ namespace {
6363struct MemRefDataFlowOpt : public MemRefDataFlowOptBase <MemRefDataFlowOpt> {
6464 void runOnFunction () override ;
6565
66- void forwardStoreToLoad (AffineLoadOp loadOp);
66+ void forwardStoreToLoad (AffineReadOpInterface loadOp);
6767
6868 // A list of memref's that are potentially dead / could be eliminated.
6969 SmallPtrSet<Value, 4 > memrefsToErase;
@@ -84,14 +84,14 @@ std::unique_ptr<OperationPass<FuncOp>> mlir::createMemRefDataFlowOptPass() {
8484
8585// This is a straightforward implementation not optimized for speed. Optimize
8686// if needed.
87- void MemRefDataFlowOpt::forwardStoreToLoad (AffineLoadOp loadOp) {
87+ void MemRefDataFlowOpt::forwardStoreToLoad (AffineReadOpInterface loadOp) {
8888 // First pass over the use list to get the minimum number of surrounding
8989 // loops common between the load op and the store op, with min taken across
9090 // all store ops.
9191 SmallVector<Operation *, 8 > storeOps;
9292 unsigned minSurroundingLoops = getNestingDepth (loadOp);
9393 for (auto *user : loadOp.getMemRef ().getUsers ()) {
94- auto storeOp = dyn_cast<AffineStoreOp >(user);
94+ auto storeOp = dyn_cast<AffineWriteOpInterface >(user);
9595 if (!storeOp)
9696 continue ;
9797 unsigned nsLoops = getNumCommonSurroundingLoops (*loadOp, *storeOp);
@@ -167,8 +167,9 @@ void MemRefDataFlowOpt::forwardStoreToLoad(AffineLoadOp loadOp) {
167167 return ;
168168
169169 // 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);
172173 // Record the memref for a later sweep to optimize away.
173174 memrefsToErase.insert (loadOp.getMemRef ());
174175 // Record this to erase later.
@@ -190,7 +191,7 @@ void MemRefDataFlowOpt::runOnFunction() {
190191 memrefsToErase.clear ();
191192
192193 // Walk all load's and perform store to load forwarding.
193- f.walk ([&](AffineLoadOp loadOp) { forwardStoreToLoad (loadOp); });
194+ f.walk ([&](AffineReadOpInterface loadOp) { forwardStoreToLoad (loadOp); });
194195
195196 // Erase all load op's whose results were replaced with store fwd'ed ones.
196197 for (auto *loadOp : loadOpsToErase)
@@ -207,7 +208,7 @@ void MemRefDataFlowOpt::runOnFunction() {
207208 // could still erase it if the call had no side-effects.
208209 continue ;
209210 if (llvm::any_of (memref.getUsers (), [&](Operation *ownerOp) {
210- return !isa<AffineStoreOp , DeallocOp>(ownerOp);
211+ return !isa<AffineWriteOpInterface , DeallocOp>(ownerOp);
211212 }))
212213 continue ;
213214
0 commit comments