1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

For lshr by 0 bits, just return *this as a short cut. This also prevents

undefined behavior when the width > 64 bits.

llvm-svn: 37153
This commit is contained in:
Reid Spencer 2007-05-17 06:26:29 +00:00
parent b81dd9fc45
commit 39e03f53ca

View File

@ -1149,6 +1149,12 @@ APInt APInt::lshr(uint32_t shiftAmt) const {
if (shiftAmt == BitWidth)
return APInt(BitWidth, 0);
// If none of the bits are shifted out, the result is *this. This avoids
// issues with shifting byt he size of the integer type, which produces
// undefined results in the code below. This is also an optimization.
if (shiftAmt == 0)
return *this;
// Create some space for the result.
uint64_t * val = new uint64_t[getNumWords()];