From f2d43093e3fc5ff63089dc68af8c8d00335f1944 Mon Sep 17 00:00:00 2001 From: Jake Fecher Date: Tue, 13 Jun 2023 11:55:25 -0500 Subject: [PATCH] Change the result of simplifying Eq and Lt to bool --- .../src/ssa_refactor/ir/instruction.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs b/crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs index bb16f144f55..11876a85a1a 100644 --- a/crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs +++ b/crates/noirc_evaluator/src/ssa_refactor/ir/instruction.rs @@ -549,15 +549,21 @@ impl Binary { dfg: &mut DataFlowGraph, lhs: FieldElement, rhs: FieldElement, - operand_type: Type, + mut operand_type: Type, ) -> Option> { let value = match self.operator { BinaryOp::Add => lhs + rhs, BinaryOp::Sub => lhs - rhs, BinaryOp::Mul => lhs * rhs, BinaryOp::Div => lhs / rhs, - BinaryOp::Eq => (lhs == rhs).into(), - BinaryOp::Lt => (lhs < rhs).into(), + BinaryOp::Eq => { + operand_type = Type::bool(); + (lhs == rhs).into() + } + BinaryOp::Lt => { + operand_type = Type::bool(); + (lhs < rhs).into() + } // The rest of the operators we must try to convert to u128 first BinaryOp::Mod => self.eval_constant_u128_operations(lhs, rhs)?, @@ -567,7 +573,6 @@ impl Binary { BinaryOp::Shl => self.eval_constant_u128_operations(lhs, rhs)?, BinaryOp::Shr => self.eval_constant_u128_operations(lhs, rhs)?, }; - // TODO: Keep original type of constant Some(dfg.make_constant(value, operand_type)) }