powdr-labs / powdr

A modular stack for zkVMs, with a focus on productivity, security and performance.
Apache License 2.0
383 stars 78 forks source link

powdr-asm optimizer: remove unused submachines, instructions, registers #682

Open leonardoalt opened 11 months ago

leonardoalt commented 11 months ago

https://github.com/powdr-labs/powdr/pull/678 adds the Poseidon submachine to the RISCV machine and a bunch of extra registers. This can be quite costly for cases that actually don't use Poseidon at all.

  1. We could have a simple assembly pass that traverses all statements, and if certain instructions are not used, removes them.
  2. When an instruction is removed, if it is delegation, we could potentially also remove the submachine instance (if all its delegations are removed)
  3. We could also remove unused registers after the passes above

This would ensure that the RISCV machine is the same as before when Poseidon is not used

leonardoalt commented 6 months ago

This could still be useful, I think @pacheco started on something similar.