Skip to content

Conversation

@harkal
Copy link
Collaborator

@harkal harkal commented Nov 19, 2025

What I did

Improve optimizations performed by algebraic optimization pass. Specifically, optimize add/sub chains.

How I did it

How to verify it

Commit message

Implements constant folding and chain optimization for add/sub operations in the Venom IR:
  - Adds `_fold_add_chain()` to collapse chains of add/sub operations into single operations
  - Adds `_trace_add_chain()` to trace through add/sub chains and compute total offsets
  - Adds `is_single_use()` helper to DFG analysis for checking variable usage
  - Optimize patterns like `add(add(x, c1), c2)` to `add(x, c1+c2)`
  - Handle sub operations in chains
  - Add foundation for shifted add chain optimization (currently disabled)

Description for the changelog

Cute Animal Picture

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

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 68.62745% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.17%. Comparing base (cb8a732) to head (91a72c1).

Files with missing lines Patch % Lines
vyper/venom/passes/algebraic_optimization.py 68.00% 27 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4778      +/-   ##
==========================================
- Coverage   93.30%   93.17%   -0.13%     
==========================================
  Files         137      137              
  Lines       19480    19580     +100     
  Branches     3367     3391      +24     
==========================================
+ Hits        18176    18244      +68     
- Misses        884      911      +27     
- Partials      420      425       +5     

☔ 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.

@harkal harkal marked this pull request as ready for review November 20, 2025 20:13
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.

1 participant