Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[InferWidths] Remove expensive walks, NFC #5523

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Jun 29, 2023

In the preprocess there seems to be an unintended use of walk. Currently we walk the entire circuit three times in the pre-process. A walk in the post-order doesn't return early even when skip() was returned (see mlir/IR/Visitor.h https://github.com/llvm/llvm-project/blob/ecfc2328ea8a1180170827d300674d0cf75a20d0/mlir/include/mlir/IR/Visitors.h#L280-L281). I think pre-order was actually intended behaivior there. This commit just replaces walks with getOps. With this commit InferWidth should visit the entire IR only once.

In the preprocess there seems to be an unintended use of `walk`.
A walk in the post-order doesn't return early even when `skip()`
was returned (see mlir/IR/Visitor.h). Probably pre-oreder was intended
here. This comit just replaces walks with `getOps`.
Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Not skipping in post-order makes sense (by the time hit the moduleop you've processed its contents already), good catch!

@uenoku uenoku merged commit fcffd28 into main Jun 30, 2023
@uenoku uenoku deleted the dev/uenoku/improve-infer-width branch June 30, 2023 00:35
@uenoku
Copy link
Member Author

uenoku commented Jun 30, 2023

Thank you for the review!

calebmkim pushed a commit to andrewb1999/circt that referenced this pull request Jul 12, 2023
In the preprocess there seems to be an unintended use of `walk`.  Currently we walk the entire circuit three times in the pre-process. A walk in the post-order doesn't return early even when `skip()` was returned (see mlir/IR/Visitor.h). This commit just replaces walks with `getOps`. With this commit InferWidth should visit the entire IR only once.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants