Skip to content

Commit

Permalink
rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Nov 10, 2024
1 parent b0105a1 commit 59e3196
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vyper/venom/passes/branch_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ def _optimize_branches(self) -> None:
fst_liveness = fst.instructions[0].liveness
snd_liveness = snd.instructions[0].liveness

cost_a, cost_b = len(fst_liveness), len(snd_liveness)

cond = term_inst.operands[0]
prev_inst = self.dfg.get_producing_instruction(cond)
if len(snd_liveness) <= len(fst_liveness) and prev_inst.opcode == "iszero":
if cost_a >= cost_b and prev_inst.opcode == "iszero":
new_cond = prev_inst.operands[0]
term_inst.operands = [new_cond, term_inst.operands[2], term_inst.operands[1]]
elif len(snd_liveness) < len(fst_liveness):
elif cost_a > cost_b:
new_cond = fn.get_next_variable()
inst = IRInstruction("iszero", [term_inst.operands[0]], output=new_cond)
bb.insert_instruction(inst, index=-1)
Expand Down

0 comments on commit 59e3196

Please sign in to comment.