diff --git a/vyper/ir/optimizer.py b/vyper/ir/optimizer.py index b770e24f58..70e014cc61 100644 --- a/vyper/ir/optimizer.py +++ b/vyper/ir/optimizer.py @@ -133,16 +133,6 @@ def _int(x): # e.g. ge x MIN_UINT256, sle x MAX_INT256 return (1, []) - if binop == "lt": - # special case, not covered by the others - if _int(args[1]) == 1: - return ("iszero", [args[0]]) - if binop == "gt": - # another special case - if _int(args[1]) == 0: - # improve codesize (not gas) - return ("iszero", [["iszero", args[0]]]) - # rewrites. in positions where iszero is preferred, (gt x 5) => (ge x 6) if is_strict != prefer_strict and _is_int(args[1]): rhs = _int(args[1]) @@ -177,6 +167,16 @@ def _int(x): return (new_op, [args[0], new_rhs]) + # some special cases that are not covered by others + if binop == "lt": + if _int(args[1]) == 1: + return ("iszero", [args[0]]) + + if binop == "gt": + if _int(args[1]) == 0: + # improve codesize (not gas) + return ("iszero", [["iszero", args[0]]]) + # def _optimize_arith( # binop: str, args: IRArgs, ann: Optional[str], parent_op: Any = None