[mlir][SCCP] Add support for propagating constants across inter-region control flow.
authorRiver Riddle <riddleriver@gmail.com>
Tue, 21 Apr 2020 09:54:14 +0000 (02:54 -0700)
committerRiver Riddle <riddleriver@gmail.com>
Tue, 21 Apr 2020 09:59:25 +0000 (02:59 -0700)
commit2eda87dfbe63bae43b81b22c8c76a3139147797b
tree67b26d786730e3ba376de51bf8051f279e03eaba
parent152d29cc74b8dd47e93255d1e8bb1361f5828d1b
[mlir][SCCP] Add support for propagating constants across inter-region control flow.

This is possible by adding two new ControlFlowInterface additions:

- A new interface, RegionBranchOpInterface
This interface allows for region holding operations to describe how control flows between regions. This interface initially contains two methods:

* getSuccessorEntryOperands
Returns the operands of this operation used as the entry arguments when entering the region at `index`, which was specified as a successor by `getSuccessorRegions`. when entering. These operands should correspond 1-1 with the successor inputs specified in `getSuccessorRegions`, and may be a subset of the entry arguments for that region.

*  getSuccessorRegions
Returns the viable successors of a region, or the possible successor when branching from the parent op. This allows for describing which regions may be executed when entering an operation, and which regions are executed after having executed another region of the parent op. For example, a structured loop operation may always enter into the loop body region. The loop body region may branch back to itself, or exit to the operation.

- A trait, ReturnLike
This trait signals that a terminator exits a region and forwards all of its operands as "exiting" values.

These additions allow for performing more general dataflow analysis in the presence of region holding operations.

Differential Revision: https://reviews.llvm.org/D78447
mlir/include/mlir/Dialect/LoopOps/LoopOps.h
mlir/include/mlir/Dialect/LoopOps/LoopOps.td
mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
mlir/include/mlir/Interfaces/ControlFlowInterfaces.td
mlir/lib/Dialect/LoopOps/LoopOps.cpp
mlir/lib/Transforms/SCCP.cpp
mlir/test/Transforms/sccp-structured.mlir [new file with mode: 0644]