[Mlir-commits] [mlir] [MLIR][SROA] Replace pattern based approach with a one-shot one (PR #85437)
Mehdi Amini
llvmlistbot at llvm.org
Sat Mar 16 12:54:43 PDT 2024
================
@@ -223,12 +215,35 @@ struct SROA : public impl::SROABase<SROA> {
SROAStatistics statistics{&destructuredAmount, &slotsWithMemoryBenefit,
&maxSubelementAmount};
- RewritePatternSet rewritePatterns(&getContext());
- rewritePatterns.add<SROAPattern>(&getContext(), statistics);
- FrozenRewritePatternSet frozen(std::move(rewritePatterns));
+ bool changed = false;
+
+ for (Region ®ion : scopeOp->getRegions()) {
+ if (region.getBlocks().empty())
+ continue;
- if (failed(applyPatternsAndFoldGreedily(scopeOp, frozen)))
- signalPassFailure();
+ OpBuilder builder(®ion.front(), region.front().begin());
+ IRRewriter rewriter(builder);
+
+ // Destructuring a slot can allow for further destructuring of other
+ // slots, destructuring is tried until no destructuring succeeds.
+ while (true) {
+ SmallVector<DestructurableAllocationOpInterface> allocators;
+ // Build a list of allocators to attempt to destructure the slots of.
+ for (Block &block : region)
+ for (Operation &op : block.getOperations())
+ if (auto allocator =
+ dyn_cast<DestructurableAllocationOpInterface>(op))
+ allocators.emplace_back(allocator);
----------------
joker-eph wrote:
LG, can you add a TODO in the code to capture this?
https://github.com/llvm/llvm-project/pull/85437
More information about the Mlir-commits
mailing list