-
Notifications
You must be signed in to change notification settings - Fork 200
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
Implementation of unsigned overflow checks is ACIR specific #4456
Labels
enhancement
New feature or request
Comments
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Mar 1, 2024
# Description ## Problem\* Avoid codegening overhead for no-op range checks generated by #4456 ## Summary\* ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
5 tasks
TomAFrench
added a commit
that referenced
this issue
May 8, 2024
# Description ## Problem\* Resolves #4456 ## Summary\* Overflow checks for unsigned integers are done in acir-gen, when converting arithmetic operations into field arithmetic. That way the semantic of the ssa unsigned operations is preserved. ## Additional Context As indicated in the issue, I did not touch signed integers, but it could be cleaner to convert them into unsigned operations (and have the signed overflow checks done with additional ssa instructions, like we do currently) ## Documentation\* Check one: - [X] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [X] I have tested the changes locally. - [X] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Tom French <tom@tomfren.ch>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Overflow checks are added on ssa gen. But the overflow checks for signed integers only make sense for the specifics of ACIR, and don't make much sense in SSA. Take this example:
This generates the following SSA:
v2 has type of u8. In SSA land, range checking a u8 to just have 8 bits should be a no-op. It only works because it knows that in ACIR additions of u8s are implemented as field additions so adding up two u8s could generate a result larger than a u8 in case of overflow.
This makes the current SSA-gen overflow checks to be no-ops in brillig, and they add overhead because we'd codegen a redundant range check (I'll open a PR to try to catch redundant range checks from generating any bytecode)
Note: this is only for unsigned. Signed overflow checks appear to apply correctly to brillig
Happy Case
We figure out a way of having efficient overflow checks with a clean abstraction. If we did at the SSA gen level the overflow checking in the style that brillig gen does it it'd generate more constraints for acir functions.
Two options that I can think of:
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
A PR was added to add the unsigned overflow checks into brillig gen directly #4445.
Additional Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: