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: replace boolean ANDs with multiplication #1954

Merged
merged 13 commits into from
Aug 2, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,16 @@ impl AcirContext {
rhs: AcirVar,
typ: AcirType,
) -> Result<AcirVar, AcirGenError> {
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
let outputs = self.black_box_function(BlackBoxFunc::AND, inputs)?;
Ok(outputs[0])
let bit_size = typ.bit_size();
if bit_size == 1 {
// Operands are booleans
// a * b
self.mul_var(lhs, rhs)
} else {
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
let outputs = self.black_box_function(BlackBoxFunc::AND, inputs)?;
Ok(outputs[0])
}
}

/// Returns an `AcirVar` that is the OR result of `lhs` & `rhs`.
Expand Down