[libc] fix shifting exact multiples of 64 in uint
authorMichael Jones <michaelrj@google.com>
Thu, 15 Dec 2022 00:51:23 +0000 (16:51 -0800)
committerMichael Jones <michaelrj@google.com>
Thu, 15 Dec 2022 21:01:32 +0000 (13:01 -0800)
commitc4b7e8a035d524c797bed79b3c7aeae0707e07b5
tree32e61663d1d959bca4b9c985b4fbae36c44a6aaa
parent2a48c5f5d597002b7e315126c69672bc11185d90
[libc] fix shifting exact multiples of 64 in uint

The internal uint class had a bug introduced recently when optimizing
the shift routines. When calculating the value of a block, it would
shift an adjacent block by 64 - the shift amount. If the shift amount
was 0, this would be a shift of 64, which is undefined for a 64 bit
integer. This patch fixes this by adding a conditional to catch this
case.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D140070
libc/src/__support/UInt.h
libc/test/src/__support/uint_test.cpp