Skip to content

Commit

Permalink
Merge branch 'master' into enum_bitwise_not
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Jun 23, 2022
2 parents 7684793 + 1e5770c commit b2c0575
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
# NOTE: if the tests get poorly distributed, run this and commit the resulting `.test_durations` file to the `vyper-test-durations` repo.
# `TOXENV=fuzzing tox -r -- --store-durations --reruns 10 --reruns-delay 1 -r aR tests/`
- name: Fetch test-durations
run: curl --location "https://raw.githubusercontent.com/vyperlang/vyper-test-durations/4d8398e581f183de986892c5a8d4ab3d05ccaab2/test_durations" -o .test_durations
run: curl --location "https://raw.githubusercontent.com/vyperlang/vyper-test-durations/ac71e77863d7f4e7e7cd19a93cf50a8c39de4845/test_durations" -o .test_durations

- name: Run Tox
run: TOXENV=fuzzing tox -r -- --splits 60 --group ${{ matrix.group }} --splitting-algorithm least_duration --reruns 10 --reruns-delay 1 -r aR tests/
Expand Down
4 changes: 2 additions & 2 deletions vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ def parse_Compare(self):
# Compare other types.
elif is_numeric_type(left.typ) and is_numeric_type(right.typ):
if left.typ.typ == right.typ.typ == "uint256":
# this works because we only have one unsigned integer type
# in the future if others are added, this logic must be expanded
# signed comparison ops work for any integer
# type BESIDES uint256
op = self._signed_to_unsigned_comparision_op(op)

elif isinstance(left.typ, BaseType) and isinstance(right.typ, BaseType):
Expand Down
11 changes: 9 additions & 2 deletions vyper/codegen/ir_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,14 @@ def is_complex_ir(self):
and self.value.lower() not in do_not_cache
)

# unused, but might be useful for analysis at some point
# get the unique symbols contained in this node, which provides
# sanity check invariants for the optimizer.
# cache because it's a perf hotspot. note that this (and other cached
# properties!) can get borked if `self.args` are mutated in such a way
# which changes the child `.unique_symbols`. in the future it would
# be good to tighten down the hatches so it is harder to modify
# IRnode member variables.
@cached_property
def unique_symbols(self):
ret = set()
if self.value == "unique_symbol":
Expand All @@ -345,7 +352,7 @@ def unique_symbols(self):
if self.value == "deploy":
children = [self.args[0], self.args[2]]
for arg in children:
s = arg.unique_symbols()
s = arg.unique_symbols
non_uniques = ret.intersection(s)
assert len(non_uniques) == 0, f"non-unique symbols {non_uniques}"
ret |= s
Expand Down
8 changes: 4 additions & 4 deletions vyper/ir/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _conservative_eq(x, y):
# ARITHMETIC AND BITWISE OPS
##

# for commutative or comparison ops, move the literal to the second
# for commutative ops, move the literal to the second
# position to make the later logic cleaner
if binop in COMMUTATIVE_OPS and _is_int(args[0]):
args = [args[1], args[0]]
Expand Down Expand Up @@ -310,7 +310,7 @@ def _conservative_eq(x, y):
return finalize(args[0].value, args[0].args)

# TODO: check me! reduce codesize for negative numbers
# if binop in {"add", "sub"} and _int(args[0], SIGNED) < 0:
# if binop in {"add", "sub"} and _int(args[1], SIGNED) < 0:
# flipped = "add" if binop == "sub" else "sub"
# return finalize(flipped, [args[0], -args[1]])

Expand Down Expand Up @@ -398,7 +398,7 @@ def _conservative_eq(x, y):

def _check_symbols(symbols, ir_node):
# sanity check that no `unique_symbol`s got optimized out.
to_check = ir_node.unique_symbols()
to_check = ir_node.unique_symbols
if symbols != to_check:
raise CompilerPanic(f"missing symbols: {symbols - to_check}")

Expand All @@ -409,7 +409,7 @@ def optimize(node: IRnode) -> IRnode:


def _optimize(node: IRnode, parent: Optional[IRnode]) -> Tuple[bool, IRnode]:
starting_symbols = node.unique_symbols()
starting_symbols = node.unique_symbols

res = [_optimize(arg, node) for arg in node.args]
argz: list
Expand Down

0 comments on commit b2c0575

Please sign in to comment.