Skip to content

[HandshakeOptimizeBitwidths] Fix subi bitwidth calculation#930

Open
zero9178 wants to merge 1 commit into
mainfrom
users/zero9179/subi-bitwidth
Open

[HandshakeOptimizeBitwidths] Fix subi bitwidth calculation#930
zero9178 wants to merge 1 commit into
mainfrom
users/zero9179/subi-bitwidth

Conversation

@zero9178
Copy link
Copy Markdown
Collaborator

The previous logic was incorrect in the case of mixed extui and extsi operands, using one bit too little to perfrom the calculation. This PR tries to fix these holes in the subi logic while also keeping it as optimized as possible by reusing as much of the logic of addi when it applies and special casing the more optimized case when both extension types match. Quite a lot of time was spent writing down somewhat of a proof of correctness in addition to testing in alive2.

Fixes #927

The previous logic was incorrect in the case of mixed `extui` and `extsi` operands, using one bit too little to perfrom the calculation. This PR tries to fix these holes in the `subi` logic while also keeping it as optimized as possible by reusing as much of the logic of `addi` when it applies and special casing the more optimized case when both extension types match.
Quite a lot of time was spent writing down somewhat of a proof of correctness in addition to testing in alive2.

Fixes #927
@zero9178 zero9178 requested a review from Jiahui17 May 21, 2026 11:56
@Jiahui17
Copy link
Copy Markdown
Member

Maybe the proof can be shortened a bit? Here is my attempt for one of the subcases

image

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect bitwidth for subi

2 participants