Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat[venom]: optimize branching #4049

Merged
merged 20 commits into from
May 28, 2024

Conversation

harkal
Copy link
Collaborator

@harkal harkal commented May 24, 2024

What I did

Added a pass to optimize inefficient branches

How I did it

How to verify it

Commit message

This commit introduces a new pass called `BranchOptimizationPass` 
that optimizes inefficient branches.

More specifically, when a branch is led with a logic inversion `ISZERO` 
we remove the `ISZERO` and invert the branch targets.

Description for the changelog

Cute Animal Picture

      /\_/\  
     ( o.o ) 
      > ^ <   "Please?"

@harkal harkal marked this pull request as ready for review May 24, 2024 07:22
moved the pass one step up so it does not need to delete instructions, they just become unused and the `RemoveUnusedVariablesPass` does the work
Copy link

codecov bot commented May 24, 2024

Codecov Report

Attention: Patch coverage is 94.73684% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 88.63%. Comparing base (96a8384) to head (1f7a792).

Current head 1f7a792 differs from pull request most recent head c329834

Please upload reports for the commit c329834 to get more accurate results.

Files Patch % Lines
vyper/venom/passes/branch_optimization.py 94.11% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4049      +/-   ##
==========================================
- Coverage   91.01%   88.63%   -2.39%     
==========================================
  Files         106      107       +1     
  Lines       15387    15326      -61     
  Branches     3384     3369      -15     
==========================================
- Hits        14005    13584     -421     
- Misses        948     1231     +283     
- Partials      434      511      +77     

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

@harkal harkal marked this pull request as draft May 24, 2024 20:46
This reverts commit 36e0b76.

Revert "lint^2"

This reverts commit 3fea134.

Revert "lint"

This reverts commit 5133ac2.

Revert "make pass handle a chain of `iszero`s"

This reverts commit 558c4d7.
@harkal harkal marked this pull request as ready for review May 27, 2024 09:15
@@ -22,6 +22,10 @@ def get_uses(self, op: IRVariable) -> list[IRInstruction]:
def get_producing_instruction(self, op: IRVariable) -> Optional[IRInstruction]:
return self._dfg_outputs.get(op)

def add_use(self, op: IRVariable, inst: IRInstruction):
uses = self._dfg_inputs.setdefault(op, [])
uses.append(inst)
Copy link
Member

Choose a reason for hiding this comment

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

note: this could be out of order from recalculating dfg from scratch, maybe in the future we should use something like set() or OrderedSet() for uses

@charles-cooper charles-cooper merged commit a7a647f into vyperlang:master May 28, 2024
155 checks passed
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.

2 participants