GitXplorerGitXplorer
c

toy-superoptimizer

public
9 stars
0 forks
1 issues

Commits

List of commits on branch main.
Verified
72f36deb93907c66ae65cf9ef06288de683cc5f0

Use enum for defining opcodes (#2)

ccorona10 committed a year ago
Verified
ae1eb16c30b108304d32a1091c694a769b8940bd

CI: Add CI pipeline (#1)

ccorona10 committed a year ago
Unverified
7015a2d8fbaf851ba621bbed348ffd255035bbd2

Run black

ccorona10 committed a year ago
Unverified
195db5c51c44a951e29077e5200121c4a53732b0

Add validation of UNPACK_SEQUENCE and fix bug

ccorona10 committed a year ago
Unverified
82425dffb7c814280684ca7f9374a3c2759503a7

Add typehint

ccorona10 committed a year ago
Unverified
d0d147aeb026b2a9966d598dcba461784bdd8f8d

Update README.md

ccorona10 committed a year ago

README

The README file for this repository.

Toy Superoptimizer

Toy superoptimizer which is inspired by https://austinhenley.com/blog/superoptimizer.html. It only supports a subset of CPython 3.11 opcodes, and it also needs to optimize searching space and algorithm. More efforts are needed to able to execute more Python codes.

** Only available in CPython 3.11 **

Code

def f():
    a, b = 3, 5
    a, b = b, a
    return a

program = Program.from_function(f)
optimizer = Superoptimizer(program)
optimizer.search()

AS-IS

LOAD_CONST 1
UNPACK_SEQUENCE 2
STORE_FAST 0
STORE_FAST 1
LOAD_FAST 1
LOAD_FAST 0
STORE_FAST 1
STORE_FAST 0
LOAD_FAST 0
RETURN_VALUE

TO-BE

LOAD_CONST 1
UNPACK_SEQUENCE 2
STORE_FAST 1
STORE_FAST 0
LOAD_FAST 0
RETURN_VALUE