[all-commits] [llvm/llvm-project] fea185: [mlir][bufferization] Add pattern to BufferDealloc...
Martin Erhart via All-commits
all-commits at lists.llvm.org
Wed Aug 23 03:41:58 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fea185d70d7e8699dd5a117743ad7b993f4ea21e
https://github.com/llvm/llvm-project/commit/fea185d70d7e8699dd5a117743ad7b993f4ea21e
Author: Martin Erhart <merhart at google.com>
Date: 2023-08-23 (Wed, 23 Aug 2023)
Changed paths:
M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocationSimplification.cpp
M mlir/test/Dialect/Bufferization/Transforms/buffer-deallocation-simplification.mlir
Log Message:
-----------
[mlir][bufferization] Add pattern to BufferDeallocationSimplification pass
This new pattern allows us to simplify the dealloc result value (by replacing
it with a constant 'true') and to trim the 'memref' operand list when we know
that all retained memrefs alias with one in the 'memref' list that has a
constant 'true' condition. Because the conditions of aliasing memrefs are
combined by disjunction, we know that once a single constant 'true' value is in
the disjunction the remaining elements don't matter anymore. This complements
the RemoveDeallocMemrefsContainedInRetained pattern which removes values from
the 'memref' list when static information is available for all retained values
by also allowing to remove values in the presence of may-aliases, but under
above mentioned condition instead.
The BufferDeallocation pass often adds dealloc operations where the memref and
retain lists are the same and all conditions are 'true'. If the operands are
all function arguments, for example, they are always determined to may-alias
which renders the other patterns invalid, but the op could still be trivially
optimized away. It would even be enough to directly compare the two operand
lists and check the conditions are all constant 'true' (plus checking for the
extract_strided_metadata operation), but this pattern is a bit more general and
still works when there are additional memrefs in the 'memref' list that actually
have to be deallocated (e.g., see regression test).
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D158518
More information about the All-commits
mailing list