Skip to content

feat[venom]: add codesize optimization pass#4333

Merged
charles-cooper merged 24 commits intovyperlang:masterfrom
charles-cooper:feat/venom-codesize
Dec 20, 2024
Merged

feat[venom]: add codesize optimization pass#4333
charles-cooper merged 24 commits intovyperlang:masterfrom
charles-cooper:feat/venom-codesize

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper commented Oct 27, 2024

What I did

How I did it

How to verify it

saves 450 bytes (2.5%) on https://gist.github.com/charles-cooper/eed70340aee2a47478ca0fc2ea6d5140

Commit message

add basic codesize optimization pass for venom which strengthens large
literals to evm computations which are shorter

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@charles-cooper charles-cooper requested a review from harkal October 27, 2024 14:38
@charles-cooper charles-cooper marked this pull request as ready for review October 27, 2024 14:38
Comment on lines +12 to +15
i = 0
while i < len(bb.instructions):
inst = bb.instructions[i]
i += 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
i = 0
while i < len(bb.instructions):
inst = bb.instructions[i]
i += 1
for inst in bb.instructions:


val = op.value

if val == (2**256 - 1):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make use of constants that we have for numbers like these

Copy link
Copy Markdown
Collaborator

@harkal harkal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made some comments in the code above. Additionally, we could add some tests for the optimization cases.

@charles-cooper
Copy link
Copy Markdown
Member Author

@cyberthirst could you take a look at the tests and see if you want to add any cases?

@charles-cooper charles-cooper merged commit a56d79d into vyperlang:master Dec 20, 2024
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

Successfully merging this pull request may close these issues.

4 participants