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
Using FieldElements to represent all integers during compile-time makes it more cumbersome and difficult to perform operations on them when they are known constants. Examples of this can be seen in the SSA pass currently: constant conversions back and forth between FieldElement, u128, and occasionally BigUInt. It is easy to forget to check the bitcount before performing FieldElement::to_u128 leading to a possible runtime error as well (e.g. on line 421 of node.rs).
Solution
Instead, we can represent all integers as arbitrarily-sized BigInts- possibly with the exception of the sized integer types which could be i128 to better perform bitwise operations.
The text was updated successfully, but these errors were encountered:
Avoid using fields until ACIR is not the right thing to do. As field is a (major) noir type, we would need to do constant folding with fields in the ssa pass.
Replacing fields with bigints is also not a good idea. I remember using them at some point (for overflow checks I believe) and I got a massive performance hit. BigInts are unlimited in theory, but in practice doing operation with big values can become very slow very quickly, so they must be used with caution as well.
I believe BigInts specifically are also not the right abstraction as we would not be able to perform bitwise operations on them. Perhaps keeping FieldElements for field types and representing integer types another way (i128 or u128?) would be more accurate.
Maybe orthogonal; in the future, it would be good to store multiple integers in a single field. If we have 2 u64s, the compiler should be able to pack that into a Field
Problem
Using FieldElements to represent all integers during compile-time makes it more cumbersome and difficult to perform operations on them when they are known constants. Examples of this can be seen in the SSA pass currently: constant conversions back and forth between FieldElement, u128, and occasionally BigUInt. It is easy to forget to check the bitcount before performing
FieldElement::to_u128
leading to a possible runtime error as well (e.g. on line 421 of node.rs).Solution
Instead, we can represent all integers as arbitrarily-sized BigInts- possibly with the exception of the sized integer types which could be i128 to better perform bitwise operations.
The text was updated successfully, but these errors were encountered: