On 4/28/23 15:47, Lawrence Hunter wrote:
static inline uint32_t ror32(uint32_t word, unsigned int shift) { - return (word >> shift) | (word << ((32 - shift) & 31)); + shift &= 31; + return (word >> shift) | (word << (32 - shift));
This is incorrect, because if shift == 0, you are now performing (word << 32). I agree with your original intent though, to mask and accept any rotation. I've changed these like so: - return (word >> shift) | (word << ((32 - shift) & 31)); + return (word >> (shift & 31)) | (word << (-shift & 31)); which also eliminates the useless subtract from word-size-before-mask. r~