Skip to content

Commit

Permalink
simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Dec 30, 2024
1 parent 8797617 commit 7799025
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,27 +984,15 @@ def build_IR(self, expr, args, kwargs, context):
],
]
elif value.typ in IntegerT.signeds():
sub = [
"with",
"ans",
["mul", value, denom_divisor],
[
"seq",
[
"assert",
[
"and",
["sgt", value, -1],
[
"or",
["eq", ["div", "ans", value], denom_divisor],
["iszero", value],
],
],
],
"ans",
],
]
product = IRnode.from_list(["mul", value, denom_divisor])
with product.cache_when_complex("ans") as (b2, product):
irlist = ["seq"]
positive = ["sge", value, 0]
safemul = ["or", ["eq", ["div", product, value], denom_divisor], ["iszero", value]]
ok = ["and", positive, safemul]
irlist.append(["assert", ok])
irlist.append(product)
sub = b2.resolve(sub)
elif value.typ == DecimalT():
sub = [
"seq",
Expand Down

0 comments on commit 7799025

Please sign in to comment.