This is an archive of the discontinued LLVM Phabricator instance.

Fix fold of 0-result 0-trip-count `affine.for`
ClosedPublic

Authored by vinayaka-bandishti on May 26 2023, 2:06 AM.

Details

Summary

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.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2023, 2:06 AM
vinayaka-bandishti requested review of this revision.May 26 2023, 2:07 AM
bondhugula added inline comments.May 26 2023, 2:33 AM
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
2484

getNumResults() != 0 to make it more obvious.

mlir/test/Dialect/Affine/canonicalize.mlir
588

We should still be able to erase such ops via a canonicalization pattern. This could be added in another revision though.

Address comments, use getNumResults.

vinayaka-bandishti marked an inline comment as done.May 26 2023, 2:44 AM
bondhugula accepted this revision.May 26 2023, 8:24 PM
This revision is now accepted and ready to land.May 26 2023, 8:24 PM
This revision was automatically updated to reflect the committed changes.