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]: binopt #4281

Open
wants to merge 99 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
123c07d
start binopt
HodanPlodky Oct 7, 2024
bb80541
better way of doing it
HodanPlodky Oct 8, 2024
79e3880
idea with equivalence analysis
HodanPlodky Oct 8, 2024
59dcdf5
more rules
HodanPlodky Oct 9, 2024
b543c36
all the rules from the original optimizer should be done
HodanPlodky Oct 9, 2024
f4650e3
all the rules from the original optimizer were not done so I added so…
HodanPlodky Oct 9, 2024
32ff283
lint
HodanPlodky Oct 9, 2024
ba0e245
different order
HodanPlodky Oct 9, 2024
5e74741
fixed test which no longer needed to be expected to fail
HodanPlodky Oct 10, 2024
3868042
removed _handle_offsets and fully moved it to the rest of the bin opt…
HodanPlodky Oct 10, 2024
1105344
truthy rules start
HodanPlodky Oct 10, 2024
8e4500e
adapted test for out of bounds check to take account static asserts e…
HodanPlodky Oct 10, 2024
eebed21
adapted test for out of bounds check to take account static asserts e…
HodanPlodky Oct 10, 2024
41960e8
Merge branch 'master' into feat/binopt
HodanPlodky Oct 10, 2024
d025563
Merge branch 'master' into feat/binopt
HodanPlodky Oct 10, 2024
4c5ee06
truthy continuation
HodanPlodky Oct 11, 2024
63fdfd5
truthy fix of eq
HodanPlodky Oct 13, 2024
3a6dbf9
more comparison ops opt
HodanPlodky Oct 13, 2024
a4e152b
better check of dict from charles
HodanPlodky Oct 15, 2024
ec0b5f2
Merge branch 'master' into feat/binopt
HodanPlodky Oct 15, 2024
c28dc4a
quick fix after merge
HodanPlodky Oct 15, 2024
2f1367f
more rules
HodanPlodky Oct 15, 2024
6150fc7
Merge branch 'master' into feat/binopt
HodanPlodky Oct 15, 2024
a4e996a
used commutative
HodanPlodky Oct 15, 2024
6f3a06f
better adding of additional instructions
HodanPlodky Oct 15, 2024
052f6bb
better rules handling start
HodanPlodky Oct 16, 2024
db0d608
better rules handling start
HodanPlodky Oct 16, 2024
83dec6a
more rules moved
HodanPlodky Oct 16, 2024
e52f8e8
Merge branch 'master' into feat/binopt
HodanPlodky Oct 17, 2024
9620ed1
more rules and more way to implement them
HodanPlodky Oct 17, 2024
372317c
more rules in different way
HodanPlodky Oct 17, 2024
7e69bf5
more rules in different way
HodanPlodky Oct 18, 2024
d084c1f
move some of the binopt into the sccp
HodanPlodky Oct 23, 2024
b2c8bd2
fix of the negative number rules
HodanPlodky Oct 24, 2024
db29ad5
removed the opts from algebraic ops
HodanPlodky Oct 24, 2024
9655460
lint + cleanup
HodanPlodky Oct 24, 2024
4b0ec3b
moved test for offsets from algebraic optimizer to sccp test
HodanPlodky Oct 24, 2024
8989fd9
added jnz to truthy
HodanPlodky Oct 24, 2024
9603690
uses calc on fly
HodanPlodky Oct 24, 2024
7bf4667
uses calc on fly fix
HodanPlodky Oct 24, 2024
22df052
sccp reduced recalc
HodanPlodky Oct 24, 2024
53d4122
used dfg instead of the different uses computation
HodanPlodky Oct 25, 2024
c63ab04
Merge branch 'master' into feat/binopt
HodanPlodky Oct 28, 2024
137cb1e
dfg calculation on fly and assert weird behaviour
HodanPlodky Oct 28, 2024
1e0aa69
sccp static assert fix
HodanPlodky Oct 29, 2024
b99ea0e
lint and comments
HodanPlodky Oct 29, 2024
4da9851
cleanup of the algebraic pass
HodanPlodky Oct 30, 2024
051d291
added the explanation for pass in except branch in test
HodanPlodky Oct 30, 2024
b140669
test sccp cleanup after debug
HodanPlodky Oct 30, 2024
565deee
sccp cleanup (comparison ops)
HodanPlodky Oct 30, 2024
39b5ee1
sccp cleanup (recalc)
HodanPlodky Oct 30, 2024
f0b7a86
lint
HodanPlodky Oct 30, 2024
180aa28
dfg cleanup
HodanPlodky Oct 30, 2024
fafc256
Merge branch 'master' into feat/binopt
HodanPlodky Oct 30, 2024
49b4f37
sccp binopt new rule
HodanPlodky Nov 5, 2024
905dcb8
small refactor
HodanPlodky Nov 5, 2024
223d35b
lint
HodanPlodky Nov 5, 2024
79fa212
Merge branch 'master' into feat/binopt
HodanPlodky Nov 6, 2024
3aa9bba
Merge branch 'master' into feat/binopt
HodanPlodky Nov 18, 2024
9c900e9
reachability
HodanPlodky Nov 19, 2024
8409c8f
test fixup
HodanPlodky Nov 19, 2024
ebee138
new rule
HodanPlodky Nov 20, 2024
58fdc94
fixes and cleanup of the new rule
HodanPlodky Nov 20, 2024
a1e39b8
Merge branch 'master' into feat/binopt
HodanPlodky Nov 20, 2024
a5fd090
Merge branch 'vyperlang:master' into feat/binopt
HodanPlodky Nov 21, 2024
cc37897
fixes
HodanPlodky Nov 22, 2024
07140cb
recursive traverse in algebraic opt
HodanPlodky Nov 22, 2024
15aea85
Merge branch 'master' into feat/binopt
HodanPlodky Nov 28, 2024
e8daa16
mem2var ignore nop ops
HodanPlodky Nov 29, 2024
eaa78eb
mem2var ignore nop ops
HodanPlodky Nov 29, 2024
d3e6143
loop traverse
HodanPlodky Dec 4, 2024
e6286e6
loop traversel fix and skip unimportant instruction
HodanPlodky Dec 5, 2024
706c4d9
changed how to match the intruction
HodanPlodky Dec 5, 2024
fe3ba6c
Merge branch 'master' into feat/binopt
HodanPlodky Dec 5, 2024
2aacb95
assert opt reenabled
HodanPlodky Dec 5, 2024
f3d25c5
moved local function into the methods
HodanPlodky Dec 10, 2024
4038881
early returns
HodanPlodky Dec 10, 2024
5bbd024
early assert
HodanPlodky Dec 10, 2024
8c8d0a3
Merge branch 'master' into feat/binopt
HodanPlodky Dec 10, 2024
8d9392b
more early returns to ignore more expensive places
HodanPlodky Dec 10, 2024
d044324
more early returns to ignore more expensive places
HodanPlodky Dec 10, 2024
0d2876f
lint
HodanPlodky Dec 10, 2024
c3e3593
removed unnecessery early return
HodanPlodky Dec 10, 2024
1ca086f
more refactor
HodanPlodky Dec 10, 2024
34201a5
lint
HodanPlodky Dec 11, 2024
b877185
combined the constant propagation and binopt
HodanPlodky Dec 11, 2024
461d0c0
optimization of pass runtime
HodanPlodky Dec 13, 2024
57d4bdd
Merge branch 'master' into feat/binopt
HodanPlodky Dec 18, 2024
9ad6236
test, improvment for operand equality and removed operation which do …
HodanPlodky Dec 18, 2024
e849f2c
Merge branch 'master' into feat/binopt
HodanPlodky Dec 18, 2024
fa5e043
lint
HodanPlodky Dec 18, 2024
49e2994
tests
HodanPlodky Dec 18, 2024
84bfa12
tests
HodanPlodky Dec 20, 2024
f4e2ace
Merge branch 'master' into feat/binopt
HodanPlodky Dec 23, 2024
a36de0b
Merge branch 'master' into feat/binopt
HodanPlodky Dec 28, 2024
119bd06
Merge branch 'master' into feat/binopt
HodanPlodky Dec 30, 2024
4436564
test and small improvements
HodanPlodky Dec 30, 2024
13aae41
Merge branch 'master' into feat/binopt
HodanPlodky Jan 1, 2025
e5533d8
moved the optimizations into the algebraic optimization pass
HodanPlodky Jan 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions tests/functional/builtins/codegen/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from vyper.compiler import compile_code
from vyper.compiler.settings import OptimizationLevel, Settings
from vyper.evm.opcodes import version_check
from vyper.exceptions import ArgumentException, CompilerPanic, TypeMismatch
from vyper.exceptions import (
ArgumentException,
CompilerPanic,
StaticAssertionException,
TypeMismatch,
)

_fun_bytes32_bounds = [(0, 32), (3, 29), (27, 5), (0, 5), (5, 3), (30, 2)]

Expand Down Expand Up @@ -533,9 +538,12 @@

@pytest.mark.parametrize("bad_code", oob_fail_list)
def test_slice_buffer_oob_reverts(bad_code, get_contract, tx_failed):
c = get_contract(bad_code)
with tx_failed():
c.do_slice()
try:
c = get_contract(bad_code)
with tx_failed():
c.do_slice()
except StaticAssertionException:
Fixed Show fixed Hide fixed
pass


# tests all 3 adhoc locations: `msg.data`, `self.code`, `<address>.code`
Expand Down
4 changes: 0 additions & 4 deletions tests/functional/codegen/features/test_constructor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import pytest

from tests.evm_backends.base_env import _compile
from vyper.exceptions import StackTooDeep
from vyper.utils import method_id


Expand Down Expand Up @@ -169,7 +166,6 @@ def get_foo() -> uint256:
assert c.get_foo() == 39


@pytest.mark.venom_xfail(raises=StackTooDeep, reason="stack scheduler regression")
def test_nested_dynamic_array_constructor_arg_2(env, get_contract):
code = """
foo: int128
Expand Down
1 change: 1 addition & 0 deletions vyper/venom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
MakeSSA(ac, fn).run_pass()
Mem2Var(ac, fn).run_pass()
MakeSSA(ac, fn).run_pass()
AlgebraicOptimizationPass(ac, fn).run_pass()

Check warning on line 52 in vyper/venom/__init__.py

View check run for this annotation

Codecov / codecov/patch

vyper/venom/__init__.py#L52

Added line #L52 was not covered by tests
SCCP(ac, fn).run_pass()
StoreElimination(ac, fn).run_pass()
SimplifyCFGPass(ac, fn).run_pass()
Expand Down
4 changes: 4 additions & 0 deletions vyper/venom/analysis/dfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
uses = self._dfg_inputs.setdefault(op, [])
uses.append(inst)

def add_output(self, op: IRVariable, inst: IRInstruction):
assert op not in self._dfg_outputs.keys()
HodanPlodky marked this conversation as resolved.
Show resolved Hide resolved
self._dfg_outputs[op] = inst

Check warning on line 32 in vyper/venom/analysis/dfg.py

View check run for this annotation

Codecov / codecov/patch

vyper/venom/analysis/dfg.py#L31-L32

Added lines #L31 - L32 were not covered by tests

def remove_use(self, op: IRVariable, inst: IRInstruction):
uses = self._dfg_inputs.get(op, [])
uses.remove(inst)
Expand Down
Loading
Loading