Details
- Reviewers
vinayaka-polymage bondhugula - Commits
- rG986bef97826f: [mlir] Remove redundant loads
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for extending this pass. Comments below.
mlir/lib/Transforms/MemRefDataFlowOpt.cpp | ||
---|---|---|
286 | We should have a doc comment here - if needed, this can be brief and refer to the larger comment above. | |
299–312 | You can actually do both in one walk, i.e., if the store -> load forward doesn't forward it, immediately run the loadCSE. (The forwarding can be made to return a LogicalStatus to check if it happened.) | |
302 | Comment here please. This isn't covered by the comment above. | |
302–303 | Please use llvm::is_contained. | |
321–339 | This is a large block of duplicated code that should be factored out and shared. You could have a function that given the storeOp and loadOp returns true/false as to whether the former may be reaching the latter, and this can be used to guard the collection of depSrcStores. | |
346–349 | Actually post dominance isn't needed here - just dominance is sufficient (but has to be used differently) and in fact will lead to a less conservative condition. But this can be fixed in a follow-up patch since the check for forwardStoreToLoad can be similarly made stronger as well freed from post-dominance info. (I already have a patch and was incidentally planning to submit it; so I can take care of this in a follow-up.) |
Address code review comments to use a utility function, combine walks, and add more comments.
mlir/lib/Transforms/MemRefDataFlowOpt.cpp | ||
---|---|---|
346–349 | With your new patch, will %v1 be replaced? affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 9 { %a1 = affine.apply affine_map<(d0, d1) -> (d1 + 1)> (%i0, %i1) affine.store %c7, %m[%i0, %a1] : memref<10x10xf32> %v0 = affine.load %m[%i0, %i1] : memref<10x10xf32> } } affine.for %i0 = 0 to 10 { affine.for %i1 = 0 to 9 { affine.store %c7, %m[%i0, %i1] : memref<10x10xf32> %v1 = affine.load %m[%i0, %i1] : memref<10x10xf32> } } |
mlir/lib/Transforms/MemRefDataFlowOpt.cpp | ||
---|---|---|
346–349 | Yes. More simply put, patterns like this as well: affine.store ... affine.for ... { affine.load ... affine.store ... ... = affine.load ... } With the current pass, the store to load in the nest won't happen. You don't need the last store to postdominate all other relevant stores. The new condition will similarly make load CSE more powerful. |
@bondhugula Thank you for the review. We'll merge it tomorrow if there are no more comments.
mlir/lib/Transforms/MemRefDataFlowOpt.cpp | ||
---|---|---|
346–349 | Great! |
We should have a doc comment here - if needed, this can be brief and refer to the larger comment above.