Skip to content

Commit 70f54b5

Browse files
author
Jerry Wu
committed
Add replaceWithZeroTripCheck to LoopLikeOpInterface
1 parent 07bf1dd commit 70f54b5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

mlir/include/mlir/Interfaces/LoopLikeInterface.td

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,28 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
220220
/*defaultImplementation=*/[{
221221
return ::mlir::failure();
222222
}]
223+
>,
224+
InterfaceMethod<[{
225+
Add a zero-trip-check around the loop to check if the loop body is ever
226+
run and return the new loop inside the check. The loop body is moved
227+
over to the new loop. Returns "failure" if the loop doesn't support
228+
this transformation.
229+
230+
After the transformation, the ops inserted to the parent region of the
231+
loop are guaranteed to be run only if the loop body runs at least one
232+
iteration.
233+
234+
Note: Ops in the loop body might be rearranged because of loop rotating
235+
to maintain the semantic. Terminators might be removed/added during this
236+
transformation.
237+
}],
238+
/*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>",
239+
/*methodName=*/"replaceWithZeroTripCheck",
240+
/*args=*/(ins "::mlir::RewriterBase &":$rewriter),
241+
/*methodBody=*/"",
242+
/*defaultImplementation=*/[{
243+
return ::mlir::failure();
244+
}]
223245
>
224246
];
225247

0 commit comments

Comments
 (0)