Previously single word would always return 0 regardless of the original sign. Multi word would return all 0s or all 1s based on the original sign. Now single word takes into account the sign as well.
llvm-svn: 301159
// Handle single word shifts with built-in ashr
if (isSingleWord()) {
if (shiftAmt == BitWidth)
- return APInt(BitWidth, 0); // undefined
+ // Undefined
+ return APInt(BitWidth,
+ SignExtend64(VAL, BitWidth) >> (APINT_BITS_PER_WORD - 1));
return APInt(BitWidth, SignExtend64(VAL, BitWidth) >> shiftAmt);
}
EXPECT_EQ(zero, one.shl(1));
EXPECT_EQ(one, one.shl(0));
EXPECT_EQ(zero, one.lshr(1));
- EXPECT_EQ(zero, one.ashr(1));
+ EXPECT_EQ(one, one.ashr(1));
// Rotates.
EXPECT_EQ(one, one.rotl(0));