[llvm] [lldb] [mlir] [mlir] Introduce replaceWithZeroTripCheck in LoopLikeOpInterface (PR #80331)

Diego Caballero via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 11:49:26 PST 2024


================
@@ -220,6 +220,31 @@ 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
----------------
dcaballe wrote:

Would it make sense to start with `scf.if` and generalize later as needed?

I think it's worth clarifying that loop rotation will only be possible for `scf.while` ops for now, that is, turning regular a "while-do" into a "do-while". That kind of rotation won't be possible at this level of abstraction for `scf.for`, hence the comment about redundant first iteration check. I think the rotation responsibility belongs to the interface itself.

If we want to make it extra configurable, we could separate the zero-trip-check method from the rotation method...

https://github.com/llvm/llvm-project/pull/80331


More information about the llvm-commits mailing list