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

feat: multiply first to allow more ACIR gen optimizations #4201

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ impl AcirContext {
// Operands are booleans.
//
// a ^ b == a + b - 2*a*b
let sum = self.add_var(lhs, rhs)?;
let prod = self.mul_var(lhs, rhs)?;
let sum = self.add_var(lhs, rhs)?;
self.add_mul_var(sum, -FieldElement::from(2_i128), prod)
} else {
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
Expand Down Expand Up @@ -457,8 +457,8 @@ impl AcirContext {
if bit_size == 1 {
// Operands are booleans
// a + b - ab
let sum = self.add_var(lhs, rhs)?;
let mul = self.mul_var(lhs, rhs)?;
let sum = self.add_var(lhs, rhs)?;
self.sub_var(sum, mul)
} else {
// Implement OR in terms of AND
Expand Down
Loading