[Mlir-commits] [mlir] [mlir][amdgpu] Fuse adjacent `MemoryCounterWaitOp` (PR #171148)
Jakub Kuderski
llvmlistbot at llvm.org
Mon Dec 8 07:18:45 PST 2025
================
@@ -596,6 +596,49 @@ LogicalResult PermlaneSwapOp::verify() {
return success();
}
+//===----------------------------------------------------------------------===//
+// MemoryCounterWaitOp
+//===----------------------------------------------------------------------===//
+
+namespace {
+/// Fuse adjacent memory counter wait ops, taking the minimum value of the
+/// counters.
+struct FuseMemoryCounterWaitOp final : OpRewritePattern<MemoryCounterWaitOp> {
+ using OpRewritePattern::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(MemoryCounterWaitOp op,
+ PatternRewriter &rewriter) const override {
+ auto next = dyn_cast<MemoryCounterWaitOp>(op->getNextNode());
+ if (!next)
+ return failure();
+
+ auto setters = {&MemoryCounterWaitOp::setLoad,
+ &MemoryCounterWaitOp::setStore, &MemoryCounterWaitOp::setDs,
+ &MemoryCounterWaitOp::setExp};
+ auto lhsVals = {op.getLoad(), op.getStore(), op.getDs(), op.getExp()};
+ auto rhsVals = {next.getLoad(), next.getStore(), next.getDs(),
+ next.getExp()};
+ for (const auto &[setter, lhs, rhs] :
+ llvm::zip(setters, lhsVals, rhsVals)) {
----------------
kuhar wrote:
can we zip_equals?
https://github.com/llvm/llvm-project/pull/171148
More information about the Mlir-commits
mailing list