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

Investigate and improve interrupt flag codegen #2987

Open
bugadani opened this issue Jan 16, 2025 · 1 comment
Open

Investigate and improve interrupt flag codegen #2987

bugadani opened this issue Jan 16, 2025 · 1 comment
Labels
performance Performance seems to be not as good as it could be peripheral:interrupt Interrupt peripheral(s)

Comments

@bugadani
Copy link
Contributor

Based on #2960 we might have some work to do - for one, we should change the other drivers as well. But we could also look into why EnumSet doesn't optimize well, too.

Ideally, if we could coerce the interrupt flag enums to use discriminants equal to their corresponding bit values (which only works if the flags are in a single register, and may be device dependent), theoretically the codegen could just be as little as read-and-mask. Can we somehow achieve that?

@wisp3rwind
Copy link
Contributor

I had a quick look at EnumSet when creating that PR.

If I understood it correctly, the way that the iterator works is as follows:

  • create a copy of the data (typically some unsigned integer)
  • in each step of the iteration, count trailing zeros to find the first set bit; then toggle that bit and yield the index

I'd guess that the compiler gives up on constant propagation through the second step and decides not to unroll the loop?

@MabezDev MabezDev added performance Performance seems to be not as good as it could be peripheral:interrupt Interrupt peripheral(s) labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance seems to be not as good as it could be peripheral:interrupt Interrupt peripheral(s)
Projects
Status: Todo
Development

No branches or pull requests

3 participants