diff --git a/src/common/bit_util.h b/src/common/bit_util.h index ae4f83cc..775ccda0 100644 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -130,6 +130,11 @@ inline T Replicate(T value, size_t element_size) { template inline T RotateRight(T value, size_t amount) { amount %= BitSize(); + + if (amount == 0) { + return value; + } + auto x = static_cast>(value); return static_cast((x >> amount) | (x << (BitSize() - amount))); }