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

Constrain statements are inefficient to Acir Gen #1442

Closed
Tracked by #1376
kevaundray opened this issue May 30, 2023 · 0 comments
Closed
Tracked by #1376

Constrain statements are inefficient to Acir Gen #1442

kevaundray opened this issue May 30, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request refactor ssa

Comments

@kevaundray
Copy link
Contributor

Problem

Currently constrain statements are seen as constrain <boolean>.

As an example, lets say we want to generate constraints for the following code:

constrain a == b

Ideally this uses 1 constraint which will approximately be a - b == 0.

In our case, it generates the following code:

let z = a == b;
constrain z;

The first line will generate constraints which will create a variable z which will indicate whether z is equal to b. This in turn creates an extra 2 constraints per equality used in a constrain statement.

Happy Case

There are many ways to solve this:

  • We can add a pass after Acir Gen which optimizes this out
  • We can change constrain bool to be constrain <expr> op <expr> so that when we process a constrain statement, we can apply the correct constraint.
  • Possibly have the SSA IR handle this (needs more thought)

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor ssa
Projects
Archived in project
Development

No branches or pull requests

2 participants