Adds a pass that can be run after buffer deallocation to simplify the deallocation operations.
In particular, there are patterns that need alias information and thus cannot be added as a regular canonicalization pattern.
This initial commit moves an incorrect canonicalization pattern from over to this new pass and fixes it by querying the alias analysis for the additional information it needs to be correct (there must not by any potential aliasing memref in the retain list other than the currently mached one).
Also, improves this pattern by considering the extract_strided_metadata operation which is inserted by the deallocation pass by default.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocationSimplification.cpp | ||
---|---|---|
58 | The implementation is doing something with aliasing. Can we capture that in the description here. | |
67 | Let's add an example that adds an arith.ori | |
97–99 | Where is the NoAlias and where is the AlwaysAlias case in the code? There's just a single "if" check below, so it looks like both are handled the same way. |
Address comments. Thanks for reviewing!
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocationSimplification.cpp | ||
---|---|---|
67 | This example actually adds an arith.ori, it was just missing. Ultimately, it will be canonicalized away by the other patterns though and all that remains of this initial dealloc is %arg1 (the condition) or %cond0 in the updated code. |
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocationSimplification.cpp | ||
---|---|---|
59–60 | let's mention that this is needed to compute the result of the op | |
66 | I think this op should have 3 return values? | |
71 | same here | |
71 | Can you add a comment in front of that: bufferization.dealloc without memrefs and conditions returns %true for every retained value. |
Fix description.
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocationSimplification.cpp | ||
---|---|---|
71 | Sure! However, it returns %false in that case because that is the identity element of OR and composes nicely in the situations we use dealloc in. |
The implementation is doing something with aliasing. Can we capture that in the description here.