Skip to content

Commit 1d48929

Browse files
authored
fix(ssa refactor): Change the result of simplifying Eq and Lt to bool (#1672)
Change the result of simplifying Eq and Lt to bool
1 parent a0cef17 commit 1d48929

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -549,15 +549,21 @@ impl Binary {
549549
dfg: &mut DataFlowGraph,
550550
lhs: FieldElement,
551551
rhs: FieldElement,
552-
operand_type: Type,
552+
mut operand_type: Type,
553553
) -> Option<Id<Value>> {
554554
let value = match self.operator {
555555
BinaryOp::Add => lhs + rhs,
556556
BinaryOp::Sub => lhs - rhs,
557557
BinaryOp::Mul => lhs * rhs,
558558
BinaryOp::Div => lhs / rhs,
559-
BinaryOp::Eq => (lhs == rhs).into(),
560-
BinaryOp::Lt => (lhs < rhs).into(),
559+
BinaryOp::Eq => {
560+
operand_type = Type::bool();
561+
(lhs == rhs).into()
562+
}
563+
BinaryOp::Lt => {
564+
operand_type = Type::bool();
565+
(lhs < rhs).into()
566+
}
561567

562568
// The rest of the operators we must try to convert to u128 first
563569
BinaryOp::Mod => self.eval_constant_u128_operations(lhs, rhs)?,
@@ -567,7 +573,6 @@ impl Binary {
567573
BinaryOp::Shl => self.eval_constant_u128_operations(lhs, rhs)?,
568574
BinaryOp::Shr => self.eval_constant_u128_operations(lhs, rhs)?,
569575
};
570-
// TODO: Keep original type of constant
571576
Some(dfg.make_constant(value, operand_type))
572577
}
573578

0 commit comments

Comments
 (0)