-
-
Notifications
You must be signed in to change notification settings - Fork 803
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]: add store elimination pass #4021
feat[venom]: add store elimination pass #4021
Conversation
Co-authored-by: Charles Cooper <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like duplication (or evolution) of
vyper/vyper/venom/passes/sccp/sccp.py
Lines 330 to 348 in ea1e4ea
def _propagate_variables(self): | |
""" | |
Copy elimination. #NOTE: Not working yet, but it's also not needed atm. | |
""" | |
for bb in self.dom.dfs_walk: | |
for inst in bb.instructions: | |
if inst.opcode == "store": | |
uses = self._get_uses(inst.output) | |
remove_inst = True | |
for usage_inst in uses: | |
if usage_inst.opcode == "phi": | |
remove_inst = False | |
continue | |
for i, op in enumerate(usage_inst.operands): | |
if op == inst.output: | |
usage_inst.operands[i] = inst.operands[0] | |
if remove_inst: | |
inst.opcode = "nop" | |
inst.operands = [] |
just checked and this looks like it reduces instructions by 1.6% and 1.9% on CurveStableSwapNG.vy and CurveCryptoMathOptimized.vy, respectively |
What I did
I added a new pass the eliminates venom
store
instructions. These instructions have no equivalent in the generated code, and serve the venom code temporarily. Removing them and forwarding the results to the actual uses, helps with further optimizations.How I did it
How to verify it
Commit message
Description for the changelog
Cute Animal Picture