Fix fold of 0-result 0-trip-count `affine.for`
authorVinayaka Bandishti <vinayaka@polymagelabs.com>
Sun, 28 May 2023 20:23:31 +0000 (01:53 +0530)
committerUday Bondhugula <uday@polymagelabs.com>
Sun, 28 May 2023 20:23:37 +0000 (01:53 +0530)
commit28c672cf83e81757023cd5ae1e044fcfcfacfc0f
tree5187008dc3fb1246923b8d00f31178c4e0de72a1
parentb66308b81f607abd5edb9aa5f2185ad92dfebfa7
Fix fold of 0-result 0-trip-count `affine.for`

Folding 0-result ops is tricky. An 0-trip-count `affine.for` that does
not return any results is not erased at the end of its usual fold
method. Attempting fold it to only results in an infinite loop of folds
on the same op. Fix this by attempting for fold away only those
`affine.for` ops that return a non-zero number of results.

Reviewed By: bondhugula

Differential Revision: https://reviews.llvm.org/D151546
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/test/Dialect/Affine/canonicalize.mlir