summaryrefslogtreecommitdiff
path: root/mlir/test/Conversion/ControlFlowToSCF
AgeCommit message (Collapse)Author
2023-09-27[mlir][cfg-to-scf] Fix invalid transformation when value is used in a ↵Markus Böck
subregion (#67544) The current loop-reduce-form transformation incorrectly assumes that any value that is used in a block that isn't in the set of loop blocks is a block outside the loop. This is correct for a pure CFG but is incorrect if operations with subregions are present. In that case, a use may be in a subregion of an operation part of the loop and incorrectly deemed outside the loop. This would later lead to transformations with code that does not verify. This PR fixes that issue by checking the transitive parent block that is in the same region as the loop rather than the immediate parent block.
2023-08-20[mlir][CFGToSCF] Visit subregions in CFGToSCF passIvan Butygin
This is useful when user already have partially-scf'ed IR or other ops with nested regions (e.g. linalg.generic). Also, improve error message and pass docs. Differential Revision: https://reviews.llvm.org/D158349
2023-08-10[mlir][cf] Add ControlFlow to SCF lifting passMarkus Böck
Structured control flow ops have proven very useful for many transformations doing analysis on conditional flow and loops. Doing these transformations on CFGs requires repeated analysis of the IR possibly leading to more complicated or less capable implementations. With structured control flow, a lot of the information is already present in the structure. This patch therefore adds a transformation making it possible to lift arbitrary control flow graphs to structured control flow operations. The algorithm used is outlined in https://dl.acm.org/doi/10.1145/2693261. The complexity in implementing the algorithm was mostly spent correctly handling block arguments in MLIR (the paper only addresses the control flow graph part of it). Note that the transformation has been implemented fully generically and does not depend on any dialect. An interface implemented by the caller is used to construct any operation necessary for the transformation, making it possible to create an interface implementation purpose fit for ones IR. For the purpose of testing and due to likely being a very common scenario, this patch adds an interface implementation lifting the control flow dialect to the SCF dialect. Note the use of the word "lifting". Unlike other conversion passes, this pass is not 100% guaranteed to convert all ControlFlow ops. Only if the input region being transformed contains a single kind of return-like operations is it guaranteed to replace all control flow ops. If that is not the case, exactly one control flow op will remain branching to regions terminating with a given return-like operation (e.g. one region terminates with `llvm.return` the other with `llvm.unreachable`). Differential Revision: https://reviews.llvm.org/D156889