Skip to content

Commit c556942

Browse files
authored
NFC: [Codegen][ROCDL] Cleanup swap pattern (#20488)
1 parent 93bb9e4 commit c556942

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/src/iree/compiler/Codegen/LLVMGPU/ConvertToROCDL.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ struct SwapSetPrioWithMFMA : public OpRewritePattern<ROCDL::SetPrioOp> {
108108
return failure();
109109
}
110110

111+
// Remove the swap attribute no matter what to avoid reapplying this
112+
// pattern.
111113
rewriter.startOpModification(setPrio);
112114
setPrio->removeDiscardableAttr(kSwapName);
113115

@@ -116,8 +118,6 @@ struct SwapSetPrioWithMFMA : public OpRewritePattern<ROCDL::SetPrioOp> {
116118

117119
for (int64_t remainingToSwap = count.getInt();
118120
remainingToSwap > 0 && current; current = current->getNextNode()) {
119-
if (!current)
120-
break;
121121
if (isa<mlir::amdgpu::MFMAOp>(current)) {
122122
--remainingToSwap;
123123
mfmaToSwap = current;
@@ -126,6 +126,7 @@ struct SwapSetPrioWithMFMA : public OpRewritePattern<ROCDL::SetPrioOp> {
126126
if (mfmaToSwap) {
127127
rewriter.moveOpAfter(setPrio, mfmaToSwap);
128128
}
129+
rewriter.finalizeOpModification(setPrio);
129130
return success();
130131
}
131132
};

0 commit comments

Comments
 (0)