[Mlir-commits] [mlir] [mlir] Add transformation to wrap scf::while in zero-trip-check (PR #81050)

Jerry Wu llvmlistbot at llvm.org
Thu Feb 8 14:22:31 PST 2024


================
@@ -183,8 +183,12 @@ FailureOr<ForOp> pipelineForLoop(RewriterBase &rewriter, ForOp forOp,
                                  bool *modifiedIR = nullptr);
 
 /// Create zero-trip-check around a `while` op and return the new loop op in the
-/// check. The while loop is rotated to avoid evaluating the condition twice. It
-/// turns:
+/// check. The while loop is rotated to avoid evaluating the condition twice
----------------
pzread wrote:

IMO users can look into the parent op for the `if` they need.

And in `do {} while (...)` case we actually don't generate the `if` (and don't rotate the0 loop) because everything in the before block is always executed (there is a parameter to control this behavior)

I don't have a strong opinion on how this method should be designed, but only returning the loop seems to be enough for now.

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


More information about the Mlir-commits mailing list