Skip to content

Add fold optimization for push N dup #2

@lionkor

Description

@lionkor

Code such as

push 1
dup

should be optimized to

push 1
push 1

or similar, depending what is faster. The main benefit would be that constant folding will hit in the latter case, if followed by, say, add.

Consider an example similar to that from the readme as of time of writing:

push 42
dup
mul

Currently, this wouldn't be constant folded to push 84, however this optimization would allow folding like that.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions