Skip to content

Precompute power if both arguments are constants (revisit) #2330

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

Merged
merged 3 commits into from
Jun 20, 2022

Conversation

MaxGraey
Copy link
Member

Precompute power operator when lhs and rhs are constants like:

const three_thousand = 3 * 10 ** 3; // will fold to 3000 during compile time

Unlike the previous PR, this only happens in optimization mode. Also added comment and TODO
Prev PR #1529

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@dcodeIO
Copy link
Member

dcodeIO commented Jun 20, 2022

Seems that the math test no longer tests ipow32 now. Would it perhaps be good to add another test there to test it?

@MaxGraey
Copy link
Member Author

Seems that the math test no longer tests ipow32 now. Would it perhaps be good to add another test there to test it?

It tests in debug more only

@dcodeIO
Copy link
Member

dcodeIO commented Jun 20, 2022

Yeah, just wondering if there would be value in also testing ipow32 when it becomes optimized. Probably not super important, but who knows what can be seen from the optimized ipow32 code when it's modified in the future, hmm.

@MaxGraey
Copy link
Member Author

I think testing in debug builds only is ok due to ipow32 is pretty simple and naive code. And if there is anything wrong with the optimizations from the release build it will appear very quickly in the rest of tests

@MaxGraey MaxGraey merged commit 291f9b6 into AssemblyScript:main Jun 20, 2022
@MaxGraey MaxGraey deleted the precompute-pow branch June 20, 2022 09:08
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