Skip to content

Commit

Permalink
feat: add special case for boolean AND in acir-gen (#3615)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Nov 28, 2023
1 parent 6f3b960 commit 824039b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,15 @@ impl AcirContext {
rhs: AcirVar,
typ: AcirType,
) -> Result<AcirVar, RuntimeError> {
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
let outputs = self.black_box_function(BlackBoxFunc::AND, inputs, 1)?;
Ok(outputs[0])
let bit_size = typ.bit_size();
if bit_size == 1 {
// Operands are booleans.
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, 1)?;
Ok(outputs[0])
}
}

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

0 comments on commit 824039b

Please sign in to comment.