Skip to content

Commit

Permalink
fixes after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
HodanPlodky committed Oct 5, 2024
1 parent ca23cde commit 018b6a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 11 additions & 7 deletions tests/unit/compiler/venom/test_common_subexpression_elimination.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.context import IRContext
from vyper.venom.passes.common_subexpression_elimination import CSE
from vyper.venom.passes.extract_literals import ExtractLiteralsPass


def test_common_subexpression_elimination():
Expand All @@ -18,8 +17,13 @@ def test_common_subexpression_elimination():
bb.append_instruction("stop")

ac = IRAnalysesCache(fn)
CSE(ac, fn).run_pass()
ExtractLiteralsPass(ac, fn).run_pass()
from vyper.venom.analysis.available_expression import AvailableExpressionAnalysis
avail: AvailableExpressionAnalysis = ac.request_analysis(AvailableExpressionAnalysis)
print(fn)
for inst in bb.instructions:
print(avail.get_available(inst))

CSE(ac, fn).run_pass(1, 5)

assert sum(1 for inst in bb.instructions if inst.opcode == "add") == 1, "wrong number of adds"
assert sum(1 for inst in bb.instructions if inst.opcode == "mul") == 1, "wrong number of muls"
Expand All @@ -39,7 +43,7 @@ def test_common_subexpression_elimination_effects_1():

ac = IRAnalysesCache(fn)

ExtractLiteralsPass(ac, fn).run_pass()
#ExtractLiteralsPass(ac, fn).run_pass()
CSE(ac, fn).run_pass()

assert sum(1 for inst in bb.instructions if inst.opcode == "add") == 2, "wrong number of adds"
Expand All @@ -61,7 +65,7 @@ def test_common_subexpression_elimination_effects_2():
bb.append_instruction("stop")

ac = IRAnalysesCache(fn)
ExtractLiteralsPass(ac, fn).run_pass()
#ExtractLiteralsPass(ac, fn).run_pass()
CSE(ac, fn).run_pass()

assert sum(1 for inst in bb.instructions if inst.opcode == "add") == 2, "wrong number of adds"
Expand All @@ -81,8 +85,8 @@ def test_common_subexpression_elimination_effect_mstore():
bb.append_instruction("stop")

ac = IRAnalysesCache(fn)
ExtractLiteralsPass(ac, fn).run_pass()
CSE(ac, fn).run_pass()
#ExtractLiteralsPass(ac, fn).run_pass()
CSE(ac, fn).run_pass(1, 5)

assert (
sum(1 for inst in bb.instructions if inst.opcode == "mstore") == 1
Expand Down
1 change: 0 additions & 1 deletion vyper/venom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def _run_passes(fn: IRFunction, optimize: OptimizationLevel) -> None:
SimplifyCFGPass(ac, fn).run_pass()
AlgebraicOptimizationPass(ac, fn).run_pass()
BranchOptimizationPass(ac, fn).run_pass()
ExtractLiteralsPass(ac, fn).run_pass()
CSE(ac, fn).run_pass(2, 10)

RemoveUnusedVariablesPass(ac, fn).run_pass()
Expand Down

0 comments on commit 018b6a9

Please sign in to comment.