Skip to content

Precompute power if both arguments are constants #1529

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

Closed
wants to merge 8 commits into from
Closed

Precompute power if both arguments are constants #1529

wants to merge 8 commits into from

Conversation

MaxGraey
Copy link
Member

@MaxGraey MaxGraey commented Oct 29, 2020

@dcodeIO I know we already talked about this and I understand this not general solution but until we haven't own IR I propose do this due to expessions like 10 ** 5, 2 ** 23 and etc is pretty popular as I see.

  • I've read the contributing guidelines

@MaxGraey MaxGraey requested a review from dcodeIO October 29, 2020 23:09
@MaxGraey MaxGraey changed the title Precalculate power if both are constants Precalculate power if both argumens are constants Oct 29, 2020
@dcodeIO
Copy link
Member

dcodeIO commented Oct 29, 2020

What do you think of making this a new pass in PostAssemblyScript.cpp on the Binaryen end? Would imagine that we can do much more there, in this case for example postprocessing calls to ~lib/math/ipow32. Also doesn't require doing additional work in untouched output, so creating a debug build is always fast.

@MaxGraey
Copy link
Member Author

Yeah, it could be binaryen's pass. But this PR useful in any case even with our custom Binaryen pass due to it works for untouched version as well. Ofc for simple cases

@MaxGraey
Copy link
Member Author

MaxGraey commented Oct 29, 2020

Btw we could extend values like 2 ** 40 and other exp >= 32 to i64 during type deducing instead stay with overflowed i32. wdyt?

@MaxGraey MaxGraey changed the title Precalculate power if both argumens are constants Precalculate power if both arguments are constants Oct 30, 2020
@MaxGraey MaxGraey changed the title Precalculate power if both arguments are constants Precompute power if both arguments are constants Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants