[Mlir-commits] [mlir] [mlir][Interfaces] `LoopLikeOpInterface`: Add helper to get yielded values (PR #67305)

Felix Schneider llvmlistbot at llvm.org
Fri Oct 6 04:07:09 PDT 2023


================
@@ -20,6 +20,19 @@ def LoopLikeOpInterface : OpInterface<"LoopLikeOpInterface"> {
     Contains helper functions to query properties and perform transformations
     of a loop. Operations that implement this interface will be considered by
     loop-invariant code motion.
+
+    Loop-carried variables can be exposed through this interface. There are
+    3 components to a loop-carried variable.
+    - The "region iter_arg" is the block argument of the entry block that
+      represents the loop-carried variable in each iteration.
+    - The "init value" is an operand of the loop op that serves as the initial
+      region iter_arg value for the first iteration (if any).
+    - The "yielded" value is the value that is forwarded from one iteration to
+      serve as the region iter_arg of the next iteration.
+
+    If one of the respective interface methods is implemented, so must the other
+    two. The interface verifier ensures that the number of types of the region
----------------
ubfx wrote:

> we cannot verify certain invariants anymore

Ah, makes sense.

> Note, `scf.forall` can still implement the `getDpsInitsMutable()` method

But what about other "looplike" Ops that don't implement the Dps Interface like `scf.parallel`? I think being able to query the tensor/buffer a `LoopLikeOpInterface` operates on is very useful for loop nest analysis - it tells us that the respective buffer is accessed "tripcount" times, where sometimes it's less important whether that is done sequentially or in parallel in the actual Operation.
So I'm not arguing against this change, it's more about not excluding `forall` and `parallel` from providing buffer information through the Interface

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


More information about the Mlir-commits mailing list