Skip to content

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

Merged
MaxGraey merged 3 commits into
AssemblyScript:mainfrom
MaxGraey:precompute-pow
Jun 20, 2022
Merged

Precompute power if both arguments are constants (revisit)#2330
MaxGraey merged 3 commits into
AssemblyScript:mainfrom
MaxGraey:precompute-pow

Conversation

@MaxGraey

Copy link
Copy Markdown
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

Comment thread src/compiler.ts
@dcodeIO

dcodeIO commented Jun 20, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
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

dcodeIO commented Jun 20, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
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