This is an archive of the discontinued LLVM Phabricator instance.

[mlir] canonicalize away zero-iteration SCF for loops
ClosedPublic

Authored by ftynse on Nov 20 2020, 10:22 AM.

Details

Summary

An SCF 'for' loop does not iterate if its lower bound is equal to its upper
bound. Remove loops where both bounds are the same SSA value as such bounds are
guaranteed to be equal. Similarly, remove 'parallel' loops where at least one
pair of respective lower/upper bounds is specified by the same SSA value.

Diff Detail

Event Timeline

ftynse created this revision.Nov 20 2020, 10:22 AM
ftynse requested review of this revision.Nov 20 2020, 10:22 AM
gysit accepted this revision.Nov 20 2020, 11:14 AM
gysit added inline comments.
mlir/test/Dialect/SCF/canonicalize.mlir
34–35

I would probably remove this test? It originally tested that the "CollapseSingleIterationLoops" pattern does not accidentally remove no/zero iteration loops. I think your new pattern/test now covers this scenario.

This revision is now accepted and ready to land.Nov 20 2020, 11:14 AM
ftynse updated this revision to Diff 307047.Nov 23 2020, 4:57 AM

Address review

ftynse marked an inline comment as done.Nov 23 2020, 4:59 AM
This revision was automatically updated to reflect the committed changes.