-
-
Notifications
You must be signed in to change notification settings - Fork 810
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: more arithmetic optimizations (#2647)"
This reverts commit efe1dbe.
- Loading branch information
1 parent
42a372e
commit 874bbcc
Showing
25 changed files
with
471 additions
and
592 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
from vyper.codegen.ir_node import IRnode | ||
from vyper.ir import optimizer | ||
|
||
optimize_list = [ | ||
(["eq", 1, 0], ["iszero", 1]), | ||
(["eq", 1, 2], ["eq", 1, 2]), # noop | ||
(["if", ["eq", 1, 2], "pass"], ["if", ["iszero", ["xor", 1, 2]], "pass"]), | ||
(["assert", ["eq", 1, 2]], ["assert", ["iszero", ["xor", 1, 2]]]), | ||
(["mstore", 0, ["eq", 1, 2]], ["mstore", 0, ["eq", 1, 2]]), # noop | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("ir", optimize_list) | ||
def test_ir_compile_fail(ir): | ||
optimized = optimizer.optimize(IRnode.from_list(ir[0])) | ||
optimized.repr_show_gas = True | ||
hand_optimized = IRnode.from_list(ir[1]) | ||
hand_optimized.repr_show_gas = True | ||
assert optimized == hand_optimized |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
def test_uclamplt(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclamplt", 2, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclamplt", 1, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclamplt", 0, 1] | ||
get_contract_from_ir(ir) | ||
|
||
|
||
def test_uclample(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclample", 2, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclample", 1, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["uclample", 0, 1] | ||
get_contract_from_ir(ir) | ||
|
||
|
||
def test_uclampgt(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclampgt", 1, 2] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclampgt", 1, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclampgt", 1, 0] | ||
get_contract_from_ir(ir) | ||
|
||
|
||
def test_uclampge(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclampge", 1, 2] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclampge", 1, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["uclampge", 1, 0] | ||
get_contract_from_ir(ir) | ||
|
||
|
||
def test_uclamplt_and_clamplt(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclamplt", 2, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclamplt", 1, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclamplt", 0, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["clamplt", 2, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["clamplt", 1, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["clamplt", 0, 1] | ||
get_contract_from_ir(ir) | ||
|
||
|
||
def test_uclample_clample(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclample", 2, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclample", 1, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["uclample", 0, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["clample", 2, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["clample", 1, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["clample", 0, 1] | ||
get_contract_from_ir(ir) | ||
|
||
|
||
def test_uclampgt_and_clampgt(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclampgt", 1, 2] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclampgt", 1, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclampgt", 1, 0] | ||
get_contract_from_ir(ir) | ||
ir = ["clampgt", 1, 2] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["clampgt", 1, 1] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["clampgt", 1, 0] | ||
get_contract_from_ir(ir) | ||
|
||
|
||
def test_uclampge_and_clampge(get_contract_from_ir, assert_compile_failed): | ||
ir = ["uclampge", 1, 2] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["uclampge", 1, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["uclampge", 1, 0] | ||
get_contract_from_ir(ir) | ||
ir = ["clampge", 1, 2] | ||
assert_compile_failed(lambda: get_contract_from_ir(ir), Exception) | ||
ir = ["clampge", 1, 1] | ||
get_contract_from_ir(ir) | ||
ir = ["clampge", 1, 0] | ||
get_contract_from_ir(ir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.