mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[Support] Ensure KnownBits::sextInReg can handle the src == dst sext-in-reg case.
This was resulting in assertions inside APInt::zext that we were extending to the same bitwidth.
This commit is contained in:
parent
7d83b7c4c8
commit
0e743a4a45
@ -85,7 +85,11 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW,
|
|||||||
|
|
||||||
KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
|
KnownBits KnownBits::sextInReg(unsigned SrcBitWidth) const {
|
||||||
unsigned BitWidth = getBitWidth();
|
unsigned BitWidth = getBitWidth();
|
||||||
assert(BitWidth >= SrcBitWidth && "Illegal sext-in-register");
|
assert(0 < SrcBitWidth && SrcBitWidth <= BitWidth &&
|
||||||
|
"Illegal sext-in-register");
|
||||||
|
|
||||||
|
if (SrcBitWidth == BitWidth)
|
||||||
|
return *this;
|
||||||
|
|
||||||
// Sign extension. Compute the demanded bits in the result that are not
|
// Sign extension. Compute the demanded bits in the result that are not
|
||||||
// present in the input.
|
// present in the input.
|
||||||
|
@ -427,7 +427,7 @@ TEST(KnownBitsTest, SExtOrTrunc) {
|
|||||||
|
|
||||||
TEST(KnownBitsTest, SExtInReg) {
|
TEST(KnownBitsTest, SExtInReg) {
|
||||||
unsigned Bits = 4;
|
unsigned Bits = 4;
|
||||||
for (unsigned FromBits = 1; FromBits != Bits; ++FromBits) {
|
for (unsigned FromBits = 1; FromBits <= Bits; ++FromBits) {
|
||||||
ForeachKnownBits(Bits, [&](const KnownBits &Known) {
|
ForeachKnownBits(Bits, [&](const KnownBits &Known) {
|
||||||
APInt CommonOne = APInt::getAllOnesValue(Bits);
|
APInt CommonOne = APInt::getAllOnesValue(Bits);
|
||||||
APInt CommonZero = APInt::getAllOnesValue(Bits);
|
APInt CommonZero = APInt::getAllOnesValue(Bits);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user