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

Morten Borup Petersen via All-commits all-commits at lists.llvm.org
Mon Sep 20 08:58:47 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 644b55d57ec76a18916d30f921781b99795f6e10
      https://github.com/llvm/llvm-project/commit/644b55d57ec76a18916d30f921781b99795f6e10
  Author: Morten Borup Petersen <morten_bp at live.dk>
  Date:   2021-09-20 (Mon, 20 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