vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.83k stars 789 forks source link

feat[venom]: add loop invariant hoisting pass #4175

Open HodanPlodky opened 1 month ago

HodanPlodky commented 1 month ago

What I did

Loop invariant hoisting

How I did it

Implemented loop detection analysis and IR pass which. The detection is done via dfs. The pass detects which instruction are not dependent on instruction within the loop and if not then the instruction is hoisted to the basic block before the loop. This is done iteratively until there are no such instruction in any loop

How to verify it

Commit message

feat[venom]: Loop invariant hoisting

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Cute rabbit

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 95.93496% with 5 lines in your changes missing coverage. Please review.

Project coverage is 88.95%. Comparing base (5067b86) to head (788bd0d). Report is 15 commits behind head on master.

Files Patch % Lines
vyper/venom/passes/loop_invariant_hosting.py 95.00% 3 Missing and 1 partial :warning:
vyper/venom/analysis/loop_detection.py 97.56% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #4175 +/- ## ========================================== - Coverage 91.34% 88.95% -2.40% ========================================== Files 109 111 +2 Lines 15606 15758 +152 Branches 3432 3469 +37 ========================================== - Hits 14256 14018 -238 - Misses 920 1232 +312 - Partials 430 508 +78 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.