MLIR  19.0.0git
Hoisting.h
Go to the documentation of this file.
1 //===- Hoisting.h - Linalg hoisting transformations -------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef MLIR_DIALECT_LINALG_TRANSFORMS_HOISTING_H_
10 #define MLIR_DIALECT_LINALG_TRANSFORMS_HOISTING_H_
11 
12 namespace mlir {
13 class Operation;
14 class RewriterBase;
15 namespace scf {
16 class ForOp;
17 } // namespace scf
18 
19 namespace linalg {
20 
21 /// Hoist vector.transfer_read/vector.transfer_write on buffers pairs out of
22 /// immediately enclosing scf::ForOp iteratively, if the following conditions
23 /// are true:
24 /// 1. The two ops access the same memref with the same indices.
25 /// 2. All operands are invariant under the enclosing scf::ForOp.
26 /// 3. No uses of the memref either dominate the transfer_read or are
27 /// dominated by the transfer_write (i.e. no aliasing between the write and
28 /// the read across the loop)
29 /// 4. The source operands for vector.transfer_{read|write} do not originate
30 /// from Ops implementing ViewLikeOpInterface (to reduce the risk of
31 /// aliasing).
32 /// To improve hoisting opportunities, call the `moveLoopInvariantCode` helper
33 /// function on the candidate loop above which to hoist. Hoisting the transfers
34 /// results in scf::ForOp yielding the value that originally transited through
35 /// memory.
36 ///
37 /// TODO: To further improve hoisting opportunities, fold aliasing memref
38 /// operations into respective vector.transfer{read|write} operations and
39 /// avoid using ops implementing ViewLikeOpInterface as the source for transfer
40 /// Ops.
41 ///
42 /// WARNING: This hoisting does not model parallelism and is generally incorrect
43 /// when used on distributed loops with memref semantics!
44 void hoistRedundantVectorTransfers(Operation *root);
45 
46 } // namespace linalg
47 } // namespace mlir
48 
49 #endif // MLIR_DIALECT_LINALG_TRANSFORMS_HOISTING_H_
void hoistRedundantVectorTransfers(Operation *root)
Hoist vector.transfer_read/vector.transfer_write on buffers pairs out of immediately enclosing scf::F...
Definition: Hoisting.cpp:76
Include the generated interface declarations.