Skip to content

Commit

Permalink
feat[venom]: remove special cases in store elimination (vyperlang#4413)
Browse files Browse the repository at this point in the history
remove special cases in store elimination, allowing elimination of
`%ret_ofst` and `%ret_size` store chains. this was previously to
protect correctness in `mem2var`, but it no longer seems to be needed.

running an additional store elimination before `mem2var` results in a
slight bytecode size improvement, since it allows more memory locations
to be promoted to stack variables.
  • Loading branch information
charles-cooper authored Dec 20, 2024
1 parent 724559a commit 9ff9080
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 1 addition & 0 deletions vyper/venom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def _run_passes(fn: IRFunction, optimize: OptimizationLevel) -> None:

SimplifyCFGPass(ac, fn).run_pass()
MakeSSA(ac, fn).run_pass()
StoreElimination(ac, fn).run_pass()
Mem2Var(ac, fn).run_pass()
MakeSSA(ac, fn).run_pass()
SCCP(ac, fn).run_pass()
Expand Down
6 changes: 0 additions & 6 deletions vyper/venom/passes/store_elimination.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ def run_pass(self):
for var, inst in dfg.outputs.items():
if inst.opcode != "store":
continue
if not isinstance(inst.operands[0], IRVariable):
continue
if inst.operands[0].name in ["%ret_ofst", "%ret_size"]:
continue
if inst.output.name in ["%ret_ofst", "%ret_size"]:
continue
self._process_store(dfg, inst, var, inst.operands[0])

self.analyses_cache.invalidate_analysis(LivenessAnalysis)
Expand Down

0 comments on commit 9ff9080

Please sign in to comment.