Skip to content

Commit 824039b

Browse files
authored
feat: add special case for boolean AND in acir-gen (#3615)
1 parent 6f3b960 commit 824039b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,15 @@ impl AcirContext {
380380
rhs: AcirVar,
381381
typ: AcirType,
382382
) -> Result<AcirVar, RuntimeError> {
383-
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
384-
let outputs = self.black_box_function(BlackBoxFunc::AND, inputs, 1)?;
385-
Ok(outputs[0])
383+
let bit_size = typ.bit_size();
384+
if bit_size == 1 {
385+
// Operands are booleans.
386+
self.mul_var(lhs, rhs)
387+
} else {
388+
let inputs = vec![AcirValue::Var(lhs, typ.clone()), AcirValue::Var(rhs, typ)];
389+
let outputs = self.black_box_function(BlackBoxFunc::AND, inputs, 1)?;
390+
Ok(outputs[0])
391+
}
386392
}
387393

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

0 commit comments

Comments
 (0)