Constraints are optimized away mistakenly by using O2
Yu3H0 opened this issue · 0 comments
Yu3H0 commented
Hello, when I use a circuit from circomlib, I found that the constraints were opmitized away. The code is as below:
pragma circom 2.0.0;
template Bits2Num(n) {
signal input in[n];
signal output out;
var lc1=0;
var e2 = 1;
for (var i = 0; i<n; i++) {
lc1 += in[i] * e2;
e2 = e2 + e2;
}
lc1 ==> out;
}
component main = Bits2Num(8);
You can see from the following picture that there is no constraints when using O2 while there is a constraint when using O0.
From your document, we can know that, the constraints can be skipped if it is linear. But I think the rule is only for the intermediate signal.
https://docs.circom.io/circom-language/circom-insight/simplification/
I would appreciate it a lot if you can add an end-of-optimization determination for this situation.