Skip to content

Commit a02ad76

Browse files
committed
Add option to enable/disable buffer elimination
1 parent 58827e0 commit a02ad76

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

lib/polygeist/Ops.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5510,6 +5510,10 @@ struct MulDivMul : public OpRewritePattern<arith::MulIOp> {
55105510
}
55115511
};
55125512

5513+
static llvm::cl::opt<bool>
5514+
BufferElim("enable-buffer-elim", llvm::cl::init(true),
5515+
llvm::cl::desc("Enable buffer elimination"));
5516+
55135517
void TypeAlignOp::getCanonicalizationPatterns(RewritePatternSet &results,
55145518
MLIRContext *context) {
55155519
results.insert<
@@ -5520,15 +5524,21 @@ void TypeAlignOp::getCanonicalizationPatterns(RewritePatternSet &results,
55205524
AlwaysAllocaScopeHoister<AffineForOp>, ConstantRankReduction,
55215525
AffineIfSinking, AffineIfSimplification, CombineAffineIfs,
55225526
MergeNestedAffineParallelLoops, PrepMergeNestedAffineParallelLoops,
5523-
MergeNestedAffineParallelIf, RemoveAffineParallelSingleIter,
5524-
BufferElimination<memref::AllocaOp>, BufferElimination<memref::AllocOp>,
5525-
AffineBufferElimination<memref::AllocaOp>,
5526-
AffineBufferElimination<memref::AllocOp>,
5527-
SimplifyDeadAllocV2<memref::AllocaOp>,
5528-
SimplifyDeadAllocV2<memref::AllocOp>, SimplifyDeadAllocV2<LLVM::AllocaOp>,
5529-
MulDivMul, MergeParallelInductions,
5530-
// RankReduction<memref::AllocaOp, scf::ParallelOp>,
5531-
AggressiveAllocaScopeInliner, InductiveVarRemoval>(context);
5527+
MergeNestedAffineParallelIf, RemoveAffineParallelSingleIter>(context);
5528+
5529+
if (BufferElim) {
5530+
results.insert<BufferElimination<memref::AllocaOp>,
5531+
BufferElimination<memref::AllocOp>,
5532+
AffineBufferElimination<memref::AllocaOp>,
5533+
AffineBufferElimination<memref::AllocOp>>(context);
5534+
}
5535+
5536+
results.insert<SimplifyDeadAllocV2<memref::AllocaOp>,
5537+
SimplifyDeadAllocV2<memref::AllocOp>,
5538+
SimplifyDeadAllocV2<LLVM::AllocaOp>, MulDivMul,
5539+
MergeParallelInductions,
5540+
// RankReduction<memref::AllocaOp, scf::ParallelOp>,
5541+
AggressiveAllocaScopeInliner, InductiveVarRemoval>(context);
55325542
}
55335543

55345544
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)