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
Since #1115 has been merged, we have a bit more space to add some useful instructions. I think 4 of such instructions could be:
u32clz - count leading zeros.
u32ctz - count trailing zeros.
u32clo - count leading ones.
u32cto - count trailing ones.
We have some of these implemented in #874, and I also believe @bitwalker Implemented handling of these in the compiler somewhere. So, we may be able to re-use some of the logic.
In addition to these, I think we should add corresponding procedures to the std::math::u64 module. This would allow us to compute these values for field elements as well (i.e., first split the field element into low/high 32-bit values using u32split and then use std::math::u64 module to compute the desired value).
One open question: in #874 we also had an implementation of ilog2 instruction on field elements. I wonder if we should also implement this one - or if the above operations can be used somehow to emulate it relatively efficiently.
Implementing the above functionality should close #807 and #863.
The text was updated successfully, but these errors were encountered:
@bobbinth I have a couple of clarifying questions:
Do we want these instructions to consume the value it is applied to? Judging by the mmr implementation — yes, but I want to make sure.
Do we want to create corresponding decorators, as it was done in the Add trailing ones instruction #874? (It's quite a silly question because in order to effectively compute these values we'll need either a decorators, or new operations)
Yes, to be consistent with other similar instructions, these instructions would work as "pop element off the stack and then push the result of the operation onto the stack.
In cases where adding a decorator can make the operation more efficient, we should add it. But I would not introduce new operations in the VM.
Since #1115 has been merged, we have a bit more space to add some useful instructions. I think 4 of such instructions could be:
u32clz
- count leading zeros.u32ctz
- count trailing zeros.u32clo
- count leading ones.u32cto
- count trailing ones.We have some of these implemented in #874, and I also believe @bitwalker Implemented handling of these in the compiler somewhere. So, we may be able to re-use some of the logic.
In addition to these, I think we should add corresponding procedures to the
std::math::u64
module. This would allow us to compute these values for field elements as well (i.e., first split the field element into low/high 32-bit values usingu32split
and then usestd::math::u64
module to compute the desired value).One open question: in #874 we also had an implementation of
ilog2
instruction on field elements. I wonder if we should also implement this one - or if the above operations can be used somehow to emulate it relatively efficiently.Implementing the above functionality should close #807 and #863.
The text was updated successfully, but these errors were encountered: