Skip to content

Commit 80a39a4

Browse files
improve optimizer rules for ge, le, gt, lt
1 parent 7ac2d7c commit 80a39a4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

vyper/ir/optimizer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ def _conservative_eq(x, y):
255255
# x + 0 == x - 0 == x | 0 == x ^ 0 == x
256256
return finalize("seq", [args[0]])
257257

258-
if binop in {"sub", "xor", "ne"} and _conservative_eq(args[0], args[1]):
259-
# x - x == x ^ x == x != x == 0
258+
if binop in {"sub", "xor", "ne", "lt", "gt"} and _conservative_eq(args[0], args[1]):
259+
# (x - x) == (x ^ x) == (x != x) == (x < x) == (x > x) == 0
260260
return finalize(0, [])
261261

262-
if binop == "eq" and _conservative_eq(args[0], args[1]):
263-
# (x == x) == 1
262+
if binop in ("eq", "le", "ge") and _conservative_eq(args[0], args[1]):
263+
# (x == x) == (x >= x) == (x <= x) == 1
264264
return finalize(1, [])
265265

266266
# TODO associativity rules

0 commit comments

Comments
 (0)