19#define GEN_PASS_DEF_LLVMSIMPLIFYCFGPASS
20#include "mlir/Dialect/LLVMIR/Transforms/Passes.h.inc"
37static LogicalResult mergeBranchBlocks(LLVM::LLVMFuncOp
func) {
39 LLVM::BrOp::getCanonicalizationPatterns(patterns,
func.getContext());
41 func.walk([&](LLVM::BrOp op) { ops.push_back(op); });
55 void runOnOperation()
override {
56 LLVM::LLVMFuncOp func = getOperation();
57 if (func.isOptimizeNone())
59 if (
failed(mergeBranchBlocks(func)))
This class allows control over how the GreedyPatternRewriteDriver works.
GreedyRewriteConfig & enableFolding(bool enable=true)
GreedyRewriteConfig & setStrictness(GreedyRewriteStrictness mode)
Include the generated interface declarations.
LogicalResult applyOpPatternsGreedily(ArrayRef< Operation * > ops, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr, bool *allErased=nullptr)
Rewrite the specified ops by repeatedly applying the highest benefit patterns in a greedy worklist dr...
@ ExistingOps
Only pre-existing ops are processed.