Skip to content

feat[venom]: add binop optimizations#4281

Merged
charles-cooper merged 219 commits intovyperlang:masterfrom
HodanPlodky:feat/binopt
Jan 20, 2025
Merged

feat[venom]: add binop optimizations#4281
charles-cooper merged 219 commits intovyperlang:masterfrom
HodanPlodky:feat/binopt

Conversation

@HodanPlodky
Copy link
Copy Markdown
Collaborator

@HodanPlodky HodanPlodky commented Oct 9, 2024

What I did

Started reimplementing the binary operation optimization and some additional from original pipeline to venom pipeline

How I did it

The optimization are done in the AlgebraicOptimizationPass since the types of optimizations nicely slots into the purpose of the pass. Most of the logic is directly taken from the original pipeline

How to verify it

Commit message

this commit adds additional binop optimizations to venom. these are
the analog of `optimize_binop` in the legacy optimizer and take us one
step closer to being able to bypass the legacy optimizer in the venom
pipeline.

the rules have been added to the algebraic optimizations pass. adding
them to the SCCP pass was considered, but to keep the rules all in one
place and to keep each pass more self-contained, they were added to the
algebraic optimizations pass, with additional SCCP passes performed for
branch/cfg reduction.

some additional machinery has been added, including `lit_eq` which
compares two IRLiterals in modular arithmetic, and InstructionUpdator,
which updates instructions while also updating the DFG in-place. this
should be useful to use for other passes in the future (although out of
scope for this PR).

additional passes have been added since they were found to improve
codesize. in particular, running AlgebraicOptimization multiple times,
and running SCCP after LoadElimination, seem to have some additional
benefits.

Description for the changelog

Cute Animal Picture

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

@HodanPlodky HodanPlodky changed the title Feat/binopt feat[venom]: binopt Oct 9, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 99.29577% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.09%. Comparing base (7136eab) to head (8642223).
Report is 74 commits behind head on master.

Files with missing lines Patch % Lines
vyper/utils.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4281      +/-   ##
==========================================
+ Coverage   92.01%   92.09%   +0.08%     
==========================================
  Files         119      119              
  Lines       16692    16931     +239     
  Branches     2805     2865      +60     
==========================================
+ Hits        15359    15593     +234     
- Misses        915      919       +4     
- Partials      418      419       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

very thorough! i reviewed that every single rule introduced in this PR has a corresponding test case. also added variants for some commutative ops.

@charles-cooper charles-cooper changed the title feat[venom]: binopt feat[venom]: add more binop optimizations Jan 15, 2025
@charles-cooper charles-cooper changed the title feat[venom]: add more binop optimizations feat[venom]: add binop optimizations Jan 20, 2025
@charles-cooper charles-cooper enabled auto-merge (squash) January 20, 2025 16:52
@charles-cooper charles-cooper merged commit 9a2cb2e into vyperlang:master Jan 20, 2025
harkal added a commit to harkal/vyper that referenced this pull request Jan 22, 2025
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.

3 participants