You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that could be replaced with the constant zero. There are two occurrences of that in the final SSA. Maybe it could also help with constant propagation, etc.
I tried implementing this with this patch:
diff --git a/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs b/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs
index df1e8f537d..14cddb7f41 100644
--- a/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs+++ b/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs@@ -103,6 +103,11 @@ impl Binary {
);
}
+ if self.lhs == self.rhs {+ let zero = dfg.make_constant(FieldElement::zero(), lhs_type);+ return SimplifyResult::SimplifiedTo(zero);+ }+
let operator = if lhs_type == NumericType::NativeField {
// Unchecked operations between fields or bools don't make sense, so we convert those to non-unchecked
// to reduce noise and confusion in the generated SSA.
It works for a simple program like this one:
fnmain(input: Field) ->pubField {
input - input
}
(it now returns Field 0 instead of doing the subtraction)
but the compiler enters a loop in the sha256 case and I don't understand why. It seems it happens during unrolling.
The text was updated successfully, but these errors were encountered:
While looking at the SSA for this code:
I found this instruction:
I think that could be replaced with the constant zero. There are two occurrences of that in the final SSA. Maybe it could also help with constant propagation, etc.
I tried implementing this with this patch:
It works for a simple program like this one:
(it now returns
Field 0
instead of doing the subtraction)but the compiler enters a loop in the sha256 case and I don't understand why. It seems it happens during unrolling.
The text was updated successfully, but these errors were encountered: