aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Transforms/LoopInvariantCodeMotion.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-29[mlir] Remove unused includes (NFC) (#146278)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2023-11-05[mlir][transform] LISH: Add transform op (#70630)Matthias Springer1-1/+3
Add a transform op for loop-invariant subset hoisting. Delete the old transform op from the Linalg dialect.
2023-11-01[mlir][Transforms] Add loop-invariant subset hoisting (LISH) transformation ↵Matthias Springer1-0/+20
(#70619) Add a loop-invariant subset hoisting pass to `mlir/Interfaces`. This pass hoist loop-invariant tensor subsets (subset extraction and subset insertion ops) from loop-like ops. Extraction ops are moved before the loop. Insertion ops are moved after the loop. The loop body operates on newly added region iter_args (one per extraction-insertion pair). This new pass will be improved in subsequent commits (to support more cases/ops) and will eventually replace `Linalg/Transforms/SubsetHoisting.cpp`. In contrast to the existing Linalg subset hoisting, the new pass is op interface-based (`SubsetOpInterface` and `LoopLikeOpInterface`).
2022-11-15[mlir] Remove `Transforms/SideEffectUtils.h` and move the methods into ↵Mahesh Ravishankar1-1/+1
`Interface/SideEffectInterfaces.h`. The methods in `SideEffectUtils.h` (and their implementations in `SideEffectUtils.cpp`) seem to have similar intent to methods already existing in `SideEffectInterfaces.h`. Move the decleration (and implementation) from `SideEffectUtils.h` (and `SideEffectUtils.cpp`) into `SideEffectInterfaces.h` (and `SideEffectInterface.cpp`). Also drop the `SideEffectInterface::hasNoEffect` method in favor of `mlir::isMemoryEffectFree` which actually recurses into the operation instead of just relying on the `hasRecursiveMemoryEffectTrait` exclusively. Differential Revision: https://reviews.llvm.org/D137857
2022-08-31[MLIR] Update pass declarations to new autogenerated filesMichele Scuttari1-3/+8
The patch introduces the required changes to update the pass declarations and definitions to use the new autogenerated files and allow dropping the old infrastructure. Reviewed By: mehdi_amini, rriddle Differential Review: https://reviews.llvm.org/D132838
2022-08-30Revert "[MLIR] Update pass declarations to new autogenerated files"Michele Scuttari1-13/+9
This reverts commit 2be8af8f0e0780901213b6fd3013a5268ddc3359.
2022-08-30[MLIR] Update pass declarations to new autogenerated filesMichele Scuttari1-9/+13
The patch introduces the required changes to update the pass declarations and definitions to use the new autogenerated files and allow dropping the old infrastructure. Reviewed By: mehdi_amini, rriddle Differential Review: https://reviews.llvm.org/D132838
2022-04-16[mlir] Refactor LICM into a utilityMogball1-11/+4
LICM is refactored into a utility that is application on any region. The implementation is moved to Transform/Utils.
2022-04-15Revert "[mlir] Refactor LICM into a utility"Stella Stamenova1-4/+11
This reverts commit 3131f808243abe3746280e016ab9459c14d9e53b. This commit broke the Windows mlir bot: https://lab.llvm.org/buildbot/#/builders/13/builds/19745
2022-04-15[mlir] Refactor LICM into a utilityMogball1-11/+4
LICM is refactored into a utility that is application on any region. The implementation is moved to Transform/Utils.
2022-03-28[mlir] Simplify LoopLikeOpInterfaceMogball1-2/+1
- Adds default implementations of `isDefinedOutsideOfLoop` and `moveOutOfLoop` since 99% of all implementations of these functions were identical - `moveOutOfLoop` takes one operation and doesn't return anything anymore. 100% of all implementations of this function would always return `success` and uses would either respond with a pass failure or an `llvm_unreachable`.
2022-01-24[mlir:Transforms] Move out the remaining non-dialect independent transforms ↵River Riddle1-78/+1
and utilities This has been a major TODO for a very long time, and is necessary for establishing a proper dialect-free dependency layering for the Transforms library. Code was moved to effectively two main locations: * Affine/ There was quite a bit of affine dialect related code in Transforms/ do to historical reasons (of a time way into MLIR's past). The following headers were moved to: Transforms/LoopFusionUtils.h -> Dialect/Affine/LoopFusionUtils.h Transforms/LoopUtils.h -> Dialect/Affine/LoopUtils.h Transforms/Utils.h -> Dialect/Affine/Utils.h The following transforms were also moved: AffineLoopFusion, AffinePipelineDataTransfer, LoopCoalescing * SCF/ Only one SCF pass was in Transforms/ (likely accidentally placed here): ParallelLoopCollapsing The SCF specific utilities in LoopUtils have been moved to SCF/Utils.h * Misc: mlir::moveLoopInvariantCode was also moved to LoopLikeInterface.h given that it is a simple utility defined in terms of LoopLikeOpInterface. Differential Revision: https://reviews.llvm.org/D117848
2022-01-05[mlir] Fix missing check on nested op values in LICMNicolas Vasilache1-2/+1
LICM checks that nested ops depend only on values defined outside before performing hoisting. However, it specifically omits to check for terminators which can lead to SSA violations. This revision fixes the incorrect behavior. Differential Revision: https://reviews.llvm.org/D116657
2021-12-20Fix clang-tidy issues in mlir/ (NFC)Mehdi Amini1-1/+1
Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D115956
2021-12-08Adjust "end namespace" comment in MLIR to match new agree'd coding styleMehdi Amini1-1/+1
See D115115 and this mailing list discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html Differential Revision: https://reviews.llvm.org/D115309
2020-11-19[mlir][BuiltinDialect] Resolve comments from D91571River Riddle1-1/+1
* Move ops to a BuiltinOps.h * Add file comments
2020-11-17[mlir][NFC] Remove references to Module.h and Function.hRiver Riddle1-1/+1
These includes have been deprecated in favor of BuiltinDialect.h, which contains the definitions of ModuleOp and FuncOp. Differential Revision: https://reviews.llvm.org/D91572
2020-06-23[NFC][MLIR] Undo anonymous namespace change from https://reviews.llvm.org/D82417Rahul Joshi1-2/+3
Undo as it does not conform to LLVM coding style (https://llvm.org/docs/CodingStandards.html#anonymous-namespaces)
2020-06-23[MLIR] [NFC] Add new line and empty line before printing modified loopRahul Joshi1-5/+5
to make the debug output readable. Differential Revision: https://reviews.llvm.org/D82417
2020-06-19[MLIR][NFC] Eliminate .getBlocks() when not neededRahul Joshi1-1/+1
Differential Revision: https://reviews.llvm.org/D82229
2020-06-05[mlir][Linalg] Add a hoistRedundantVectorTransfers helper functionNicolas Vasilache1-1/+2
This revision adds a helper function to hoist vector.transfer_read / vector.transfer_write pairs out of immediately enclosing scf::ForOp iteratively, if the following conditions are true: 1. The 2 ops access the same memref with the same indices. 2. All operands are invariant under the enclosing scf::ForOp. 3. No uses of the memref either dominate the transfer_read or are dominated by the transfer_write (i.e. no aliasing between the write and the read across the loop) To improve hoisting opportunities, call the `moveLoopInvariantCode` helper function on the candidate loop above which to hoist. Hoisting the transfers results in scf::ForOp yielding the value that originally transited through memory. This revision additionally exposes `moveLoopInvariantCode` as a helper in LoopUtils.h and updates SliceAnalysis to support return scf::For values and allow hoisting across multiple scf::ForOps. Differential Revision: https://reviews.llvm.org/D81199
2020-05-15[MLIR] Continue renaming of "SideEffects"Stephen Neuendorffer1-1/+1
MLIRSideEffects -> MLIRSideEffectInterfaces SideEffects.h -> SideEffectInterfaces.h SideEffects.cpp -> SideEffectInterface.cpp Note that I haven't renamed TableGen/SideEffects.h or TableGen/SideEffects.cpp find -name "*.h" -exec sed -i "s/SideEffects.h/SideEffectInterfaces.h/" "{}" \; find -name "CMakeLists.txt" -exec sed -i "s/MLIRSideEffects/MLIRSideEffectInterfaces/" "{}" \; Differential Revision: https://reviews.llvm.org/D79890
2020-04-07[mlir][Pass] Update the PassGen to generate base classes instead of utilitiesRiver Riddle1-6/+2
Summary: This is much cleaner, and fits the same structure as many other tablegen backends. This was not done originally as the CRTP in the pass classes made it overly verbose/complex. Differential Revision: https://reviews.llvm.org/D77367
2020-04-07[mlir][Pass] Remove the use of CRTP from the Pass classesRiver Riddle1-1/+2
This revision removes all of the CRTP from the pass hierarchy in preparation for using the tablegen backend instead. This creates a much cleaner interface in the C++ code, and naturally fits with the rest of the infrastructure. A new utility class, PassWrapper, is added to replicate the existing behavior for passes not suitable for using the tablegen backend. Differential Revision: https://reviews.llvm.org/D77350
2020-04-01[mlir][Pass] Add support for generating pass utilities via tablegenRiver Riddle1-1/+4
This revision adds support for generating utilities for passes such as options/statistics/etc. that can be inferred from the tablegen definition. This removes additional boilerplate from the pass, and also makes it easier to remove the reliance on the pass registry to provide certain things(e.g. the pass argument). Differential Revision: https://reviews.llvm.org/D76659
2020-04-01[mlir][Pass] Add a tablegen backend for defining Pass informationRiver Riddle1-4/+0
This will greatly simplify a number of things related to passes: * Enables generation of pass registration * Enables generation of boiler plate pass utilities * Enables generation of pass documentation This revision focuses on adding the basic structure and adds support for generating the registration for passes in the Transforms/ directory. Future revisions will add more support and move more passes over. Differential Revision: https://reviews.llvm.org/D76656
2020-03-14[mlir][NFC] Move the LoopLike interface out of Transforms/ and into Interfaces/River Riddle1-9/+2
Differential Revision: https://reviews.llvm.org/D76155
2020-03-12[mlir][SideEffects] Replace HasNoSideEffect with the memory effect interfaces.River Riddle1-7/+9
HasNoSideEffect can now be implemented using the MemoryEffectInterface, removing the need to check multiple things for the same information. This also removes an easy foot-gun for users as 'Operation::hasNoSideEffect' would ignore operations that dynamically, or recursively, have no side effects. This also leads to an immediate improvement in some of the existing users, such as DCE, now that they have access to more information. Differential Revision: https://reviews.llvm.org/D76036
2020-03-10[mlir][NFC] Move the interfaces and traits for side effects out of IR/ to ↵River Riddle1-0/+1
Interfaces/ Summary: Interfaces/ is the designated directory for these types of interfaces, and also removes the need for including them directly in IR/. Differential Revision: https://reviews.llvm.org/D75886
2020-03-09[mlir][SideEffects] Replace the old SideEffects dialect interface with the ↵River Riddle1-29/+20
newly added op interfaces/traits. Summary: The old interface was a temporary stopgap to allow for implementing simple LICM that took side effects of region operations into account. Now that MLIR has proper support for specifying memory effects, this interface can be deleted. Differential Revision: https://reviews.llvm.org/D74441
2020-01-26Mass update the MLIR license header to mention "Part of the LLVM project"Mehdi Amini1-1/+1
This is an artifact from merging MLIR into LLVM, the file headers are now aligned with the rest of the project.
2020-01-11[mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is ↵River Riddle1-1/+1
properly value-typed. Summary: These were temporary methods used to simplify the transition. Reviewed By: antiagainst Differential Revision: https://reviews.llvm.org/D72548
2019-12-23NFC: Replace ValuePtr with Value and remove it now that Value is value-typed.River Riddle1-2/+2
ValuePtr was a temporary typedef during the transition to a value-typed Value. PiperOrigin-RevId: 286945714
2019-12-23Adjust License.txt file to use the LLVM licenseMehdi Amini1-13/+4
PiperOrigin-RevId: 286906740
2019-12-22NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to ↵River Riddle1-2/+2
Value being value-typed. This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics. PiperOrigin-RevId: 286844725
2019-12-18NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle1-1/+1
in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
2019-10-16Implement simple loop-invariant-code-motion based on dialect interfaces.Stephan Herhut1-184/+88
PiperOrigin-RevId: 275004258
2019-09-13NFC: Finish replacing FunctionPassBase/ModulePassBase with OpPassBase.River Riddle1-1/+1
These directives were temporary during the generalization of FunctionPass/ModulePass to OpPass. PiperOrigin-RevId: 268970259
2019-08-30Add a canonicalization to erase empty AffineForOps.River Riddle1-6/+0
AffineForOp themselves are pure and can be removed if there are no internal operations. PiperOrigin-RevId: 266481293
2019-08-29Refactor the 'walk' methods for operations.River Riddle1-1/+1
This change refactors and cleans up the implementation of the operation walk methods. After this refactoring is that the explicit template parameter for the operation type is no longer needed for the explicit op walks. For example: op->walk<AffineForOp>([](AffineForOp op) { ... }); is now accomplished via: op->walk([](AffineForOp op) { ... }); PiperOrigin-RevId: 266209552
2019-08-20NFC: Move AffineOps dialect to the Dialect sub-directory.River Riddle1-1/+1
PiperOrigin-RevId: 264482571
2019-08-19NFC: Move LLVMIR, SDBM, and StandardOps to the Dialect/ directory.River Riddle1-1/+1
PiperOrigin-RevId: 264193915
2019-08-17Change from llvm::make_unique to std::make_uniqueJacques Pienaar1-1/+1
Switch to C++14 standard method as llvm::make_unique has been removed ( https://reviews.llvm.org/D66259). Also mark some targets as c++14 to ease next integrates. PiperOrigin-RevId: 263953918
2019-08-12Express ownership transfer in PassManager API through std::unique_ptr (NFC)Mehdi Amini1-2/+2
Since raw pointers are always passed around for IR construct without implying any ownership transfer, it can be error prone to have implicit ownership transferred the same way. For example this code can seem harmless: Pass *pass = .... pm.addPass(pass); pm.addPass(pass); pm.run(module); PiperOrigin-RevId: 263053082
2019-07-16Move affine.for and affine.if to ODSNicolas Vasilache1-4/+4
As the move to ODS is made, body and region names across affine and loop dialects are uniformized. PiperOrigin-RevId: 258416590
2019-07-03Globally change load/store/dma_start/dma_wait operations over to ↵Andy Davis1-6/+8
affine.load/store/dma_start/dma_wait. In most places, this is just a name change (with the exception of affine.dma_start swapping the operand positions of its tag memref and num_elements operands). Significant code changes occur here: *) Vectorization: LoopAnalysis.cpp, Vectorize.cpp *) Affine Transforms: Transforms/Utils/Utils.cpp PiperOrigin-RevId: 256395088
2019-06-09NFC: Rename FuncBuilder to OpBuilder and refactor to take a top level region ↵River Riddle1-1/+1
instead of a function. PiperOrigin-RevId: 251563898
2019-06-01 Loop invariant code motion - remove reliance on getForwardSlice. Add ↵Amit Sabne1-22/+151
more tests. -- PiperOrigin-RevId: 250950703
2019-05-20 Replace Operation::isa with llvm::isa.River Riddle1-2/+2
-- PiperOrigin-RevId: 247789235
2019-05-20 Cleanups and simplifications to code, noticed by inspection. NFC.Chris Lattner1-17/+7
-- PiperOrigin-RevId: 247758075