[MLIR][SCF] Remove loop invariant arguments of scf.while
authorAbhishek Varma <abhishek.varma@cerebras.net>
Thu, 3 Feb 2022 16:09:51 +0000 (17:09 +0100)
committerAlex Zinenko <zinenko@google.com>
Thu, 3 Feb 2022 16:13:25 +0000 (17:13 +0100)
commit59b23c4aecccd8a0687c71b3afc55fd233b935c2
tree3d0b8ea44b9386dcdc30ac8aa77d2a6b7d42ba84
parent42fc05e09c38460d149e8097a3cb1e1f481e7ac2
[MLIR][SCF] Remove loop invariant arguments of scf.while

-- This commit adds a canonicalization pattern on scf.while to remove
   the loop invariant arguments.
-- An argument is considered loop invariant if the iteration argument value is
   the same as the corresponding one being yielded (at the same position) in both
   the before/after block of scf.while.
-- For the arguments removed, their use within scf.while and their corresponding
   scf.while's result are replaced with their corresponding initial value.

Signed-off-by: Abhishek Varma <abhishek.varma@polymagelabs.com>
Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D116923
mlir/lib/Dialect/SCF/SCF.cpp
mlir/test/Dialect/SCF/canonicalize.mlir