[Mlir-commits] [mlir] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)
Jerry Wu
llvmlistbot at llvm.org
Wed Feb 7 10:44:42 PST 2024
================
@@ -220,6 +220,30 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
/*defaultImplementation=*/[{
return ::mlir::failure();
}]
+ >,
+ InterfaceMethod<[{
+ Add a zero-trip-check around the loop to check if the loop body is ever
+ run and return the same loop (moved) or a new loop (replaced) inside the
+ check. Returns "failure" if the loop doesn't support the transformation.
+
+ After the transformation, the ops inserted to the parent region of the
+ loop are guaranteed to be run only if the loop body runs at least one
+ iteration.
+
+ Note: Ops in the loop body might be rearranged because of loop rotating
+ to maintain the semantic. Terminators might be removed/added during this
+ transformation. Also callers are not required to check the side-effect
+ of loop condition, so the transformation needs to consider that to make
+ sure the loop behavior is unchanged when moving the condition out of the
+ loop for the zero-trip-check.
+ }],
+ /*retTy=*/"::mlir::FailureOr<::mlir::LoopLikeOpInterface>",
+ /*methodName=*/"replaceWithZeroTripCheck",
----------------
pzread wrote:
SG. Done.
https://github.com/llvm/llvm-project/pull/80331
More information about the Mlir-commits
mailing list