This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Make isPerfectlyNested check more efficient
ClosedPublic

Authored by bondhugula on Apr 18 2020, 7:12 AM.

Details

Summary

Make mlir::isPerfectlyNested more efficient; use O(1) check instead of
O(N) size() method.

Diff Detail

Event Timeline

bondhugula created this revision.Apr 18 2020, 7:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 18 2020, 7:12 AM
mehdi_amini accepted this revision.Apr 18 2020, 10:39 AM
This revision is now accepted and ready to land.Apr 18 2020, 10:39 AM
rriddle added inline comments.Apr 18 2020, 10:59 AM
mlir/lib/Transforms/Utils/LoopUtils.cpp
715

nit: You could use llvm::hasNItems(block->begin(), block->end(), 2). We could also add a range based version to make it more usable.

bondhugula marked 2 inline comments as done.Apr 18 2020, 11:28 AM
bondhugula added inline comments.
mlir/lib/Transforms/Utils/LoopUtils.cpp
715

This would lead to one extra conditional check since it wouldn't factor in the additional information that this block is known to have at least one element. But that method is useful in general - thanks.

This revision was automatically updated to reflect the committed changes.
bondhugula marked an inline comment as done.