scroll-tech / scroll-tech/ceno
Unify ADD and ADDI
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 153
- Forks
- 43
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 4
Description
Our internal instruction format (InsnRecord) already supports instructions with both two input registers and an immediate.
That means we can decode both ADD and ADDI into the same internal instruction that acts like rd := wrap_around(rs1 + rs2 + imm). The same is applicable for other pairs of register and immediate operations. Like immediate left shift and multiplication.
This should result in fewer and simpler circuits.
Note that we only need to handle wrap around once, because in all instructions either at least one of rs2 or immediate operand are zero.
This suggestion assumes that we can unify instructions like ADD and ADDI without any extra conditional logic in the circuits (which I am confident in, having done this kind of thing before), and it also assumes that having fewer circuits helps with simplicity and performance, especially performance of recursive proving.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing InsnRecord through instruction decoding and the circuits that handle ADD and ADDI. Determine whether the register and immediate forms can share one internal instruction without extra conditional logic, then assess the analogous shift and multiplication pairs. Done means the applicable pairs are unified while preserving wrap-around behavior and reducing circuit duplication.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100