[all-commits] [llvm/llvm-project] 032cb1: [MLIR][SCF] Add for-to-while loop transformation pass

Morten Borup Petersen via All-commits all-commits at lists.llvm.org
Tue Sep 21 01:10:19 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 032cb1650fe62f9c93b0a0857e21597b2d11a69f
      https://github.com/llvm/llvm-project/commit/032cb1650fe62f9c93b0a0857e21597b2d11a69f
  Author: Morten Borup Petersen <morten_bp at live.dk>
  Date:   2021-09-21 (Tue, 21 Sep 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/SCF/Passes.h
    M mlir/include/mlir/Dialect/SCF/Passes.td
    M mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt
    A mlir/lib/Dialect/SCF/Transforms/ForToWhile.cpp
    A mlir/test/Dialect/SCF/for-loop-to-while-loop.mlir

  Log Message:
  -----------
  [MLIR][SCF] Add for-to-while loop transformation pass

This pass transforms SCF.ForOp operations to SCF.WhileOp. The For loop condition is placed in the 'before' region of the while operation, and indctuion variable incrementation + the loop body in the 'after' region. The loop carried values of the while op are the induction variable (IV) of the for-loop + any iter_args specified for the for-loop.
Any 'yield' ops in the for-loop are rewritten to additionally yield the (incremented) induction variable.

This transformation is useful for passes where we want to consider structured control flow solely on the basis of a loop body and the computation of a loop condition. As an example, when doing high-level synthesis in CIRCT, the incrementation of an IV in a for-loop is "just another part" of a circuit datapath, and what we really care about is the distinction between our datapath and our control logic (the condition variable).

Differential Revision: https://reviews.llvm.org/D108454




More information about the All-commits mailing list