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

Improve handling of exponentiations #149

Closed
tohrnii opened this issue Feb 16, 2023 · 3 comments
Closed

Improve handling of exponentiations #149

tohrnii opened this issue Feb 16, 2023 · 3 comments

Comments

@tohrnii
Copy link
Contributor

tohrnii commented Feb 16, 2023

Codegen for something like a^b where both a and b are constants results in something like:

(E::from(a_u64)).exp(E::PositiveInteger::from(b_u64))

Ideally it should be something like:

E::from(a_u64.pow(b))

and eventually this should be further optimized to just be

E::from(8_u64)

where a = 2 and b = 3.

This will involve making changes to both IR and codegen where evaluating the exponent before generating code could be an optimization pass.

Originally proposed by @bobbinth in #136 (comment)

@jan-ferdinand
Copy link

Not that I have any knowledge of the current status nor any say in this, but constant folding sounds like a good idea in general, not just for exponentiation.

@tohrnii
Copy link
Contributor Author

tohrnii commented Feb 16, 2023

@jan-ferdinand Thanks for pointing it out. Agreed, constant folding is something we plan to do as part of adding some optimization passes to the IR in the future.

@bobbinth
Copy link
Contributor

bobbinth commented Jul 2, 2023

Superseded by #333.

@bobbinth bobbinth closed this as completed Jul 2, 2023
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

No branches or pull requests

3 participants