noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
894 stars 199 forks source link

Deduplicate intrinsics with side effects they're under the same predicate #6533

Open TomAFrench opened 3 hours ago

TomAFrench commented 3 hours ago

We currently do not deduplicate any intrinics which have side effects. This results in us not deduplicating instrinsics which we should be able to (example given in #6527 where we do not deduplicate Intrinsic::ToRadix calls of the same variable in the same block).

We essentially need to make deduplication of these instructions aware of deduplicate_with_predicate similarly to how we do for other instructions.

jfecher commented 2 hours ago

We can add the && deduplicate_with_predicate clause but we also need to actually match on them more closely in that case since we still wouldn't want to deduplicate e.g. println(1)