vyper icon indicating copy to clipboard operation
vyper copied to clipboard

Add _optimize_inefficient_jumps()

Open harkal opened this issue 2 years ago • 0 comments

What I did

This patch adds an additional peephole optimisation rule for the sequence:

_sym_common JUMPI _sym_x JUMP _sym_common JUMPDEST

which it coverts the equivalent

ISZERO _sym_x JUMPI _sym_common JUMPDEST

These sequences mostly occur with the new experimental code generator, but it appears to rarely occur with the current one, too. For example ERC1155ownable.vy saves 24 bytes.

How I did it

Implemented _optimize_inefficient_jumps() in compile_ir.vy and chained it to the _optimize_assembly() function.

harkal avatar Aug 21 '23 13:08 harkal