Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant-folding on generated TASM #47

Open
13 tasks
Sword-Smith opened this issue Sep 27, 2023 · 0 comments
Open
13 tasks

Constant-folding on generated TASM #47

Sword-Smith opened this issue Sep 27, 2023 · 0 comments

Comments

@Sword-Smith
Copy link
Contributor

Sword-Smith commented Sep 27, 2023

Generated TASM can often be simplified before it is executed on the VM. Consider for example

push 14
push 15
add

this can be replaced by

push 29

When we resolve addresses of list items and structs, we generate a lot of TASM code that can be simplified this way.

Optimally, everything that can be calculated at compile-time should be. Such that the VM's trace lengths can be minimized. A good place to start would be to implment TASM-constant-folding for these patterns

  • push a push b add
  • push a push b mul
  • push a push b eq
  • push 0 eq push 0 eq push 0 eq -> push 0 eq
  • push a push b lt
  • push a push b and
  • push a push b xor
  • push a push b pow
  • push a push b div
  • push a log_2_floor
  • push a invert
  • push a pop_count
  • All four XFieldElement-specific instructions

Concretely, this optimization step could be implemented as a method on InnerFunctionTasmCode but other interfaces are possible, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant