Skip to content

Commit

Permalink
removed unnecessary update
Browse files Browse the repository at this point in the history
  • Loading branch information
HodanPlodky committed Jan 13, 2025
1 parent ee70d8b commit ed2ac2d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions vyper/venom/passes/algebraic_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,7 @@ def _handle_inst_peephole(self, inst: IRInstruction):

# rewrite comparisons by adding an `iszero`, e.g.
# `x > N` -> `x >= (N + 1)`
def _rewrite_comparison(
self, inst: IRInstruction, opcode: str, operands: list[IROperand]
) -> Optional[IRLiteral]:
def _rewrite_comparison(self, opcode: str, operands: list[IROperand]) -> Optional[IRLiteral]:
val = operands[0].value
unsigned = "s" not in opcode
if "gt" in opcode:
Expand All @@ -389,9 +387,6 @@ def _rewrite_comparison(
if _wrap256(val, unsigned) != val:
return None

n_opcode = _flip_comparison_op(opcode)
self.updater._update(inst, n_opcode, [IRLiteral(val), operands[1]])

return IRLiteral(val)

# do this rule after the other algebraic optimizations because
Expand Down Expand Up @@ -421,7 +416,7 @@ def _handle_inst_ge_le(self, inst: IRInstruction):
if len(n_uses) != 1 or n_uses.first().opcode == "assert":
return

val = self._rewrite_comparison(inst, opcode, operands)
val = self._rewrite_comparison(opcode, operands)
if val is None:
return
new_opcode = _flip_comparison_op(opcode)
Expand Down Expand Up @@ -455,7 +450,7 @@ def _handle_assert_inst(self, inst: IRInstruction):
if not isinstance(src.operands[0], IRLiteral):
return

val = self._rewrite_comparison(src, opcode, src.operands)
val = self._rewrite_comparison(opcode, src.operands)
if val is None:
return
new_opcode = _flip_comparison_op(opcode)
Expand Down

0 comments on commit ed2ac2d

Please sign in to comment.