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 FuncOp; 14 15 namespace linalg { 16 17 /// Hoist alloc/dealloc pairs and alloca op out of immediately enclosing 18 /// scf::ForOp if both conditions are true: 19 /// 1. All operands are defined outside the loop. 20 /// 2. All uses are ViewLikeOp or DeallocOp. 21 // TODO: generalize on a per-need basis. 22 void hoistViewAllocOps(FuncOp func); 23 24 /// Hoist vector.transfer_read/vector.transfer_write pairs out of immediately 25 /// enclosing scf::ForOp iteratively, if the following conditions are true: 26 /// 1. The two ops access the same memref with the same indices. 27 /// 2. All operands are invariant under the enclosing scf::ForOp. 28 /// 3. No uses of the memref either dominate the transfer_read or are 29 /// dominated by the transfer_write (i.e. no aliasing between the write and 30 /// the read across the loop) 31 /// To improve hoisting opportunities, call the `moveLoopInvariantCode` helper 32 /// function on the candidate loop above which to hoist. Hoisting the transfers 33 /// results in scf::ForOp yielding the value that originally transited through 34 /// memory. 35 // TODO: generalize on a per-need basis. 36 void hoistRedundantVectorTransfers(FuncOp func); 37 38 } // namespace linalg 39 } // namespace mlir 40 41 #endif // MLIR_DIALECT_LINALG_TRANSFORMS_HOISTING_H_ 42