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
The _SHL and _SHR functions are very handy. However, bitwise Rotate Left and Rotate Right can also be extremely helpful.
Both x86 and x86-64 instruction set have native support for ROL & ROR - https://www.amd.com/system/files/TechDocs/24594.pdf
These can be implemented like how we have SHL & SHR today.
Seems reasonable enough to me, I'd be curious to hear from others but it seems like it would fit well along with _SHR, _SHL, and also the bit operations.
The only thing that I think is notable from an implementation perspective is that the size of the operand is more relevant for rotations. So where-as right now we only have a single func__shr implementation that takes an unsigned 64-bit integer, rotations care about the operand size and we'll need separate implementations/overloads/etc. for each supported integer type so that the bits on the end correctly get rotated to the beginning.
It would also be important to define which numbers are valid for rotations. For the rotation count it's probably fine to simply say any positive integer is a valid rotation, as we can mask it with 64/32/16/8 and the rotate will give the same result. Negatives should give an 'illegal function call' error I think.
The _SHL and _SHR functions are very handy. However, bitwise
Rotate Left
andRotate Right
can also be extremely helpful.Both x86 and x86-64 instruction set have native support for ROL & ROR - https://www.amd.com/system/files/TechDocs/24594.pdf
These can be implemented like how we have SHL & SHR today.
The text was updated successfully, but these errors were encountered: