mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-24 13:15:36 +00:00
Only do masking for unsigned values!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2504 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5f06e10a84
commit
d661937352
@ -249,16 +249,15 @@ static Constant *getMaxValue(const Type *Ty) {
|
|||||||
if (Ty == Type::BoolTy)
|
if (Ty == Type::BoolTy)
|
||||||
return ConstantBool::True;
|
return ConstantBool::True;
|
||||||
|
|
||||||
// Calculate -1 casted to the right type...
|
|
||||||
unsigned TypeBits = Ty->getPrimitiveSize()*8;
|
|
||||||
uint64_t Val = (uint64_t)-1LL; // All ones
|
|
||||||
Val >>= 64-TypeBits; // Shift out unwanted 1 bits...
|
|
||||||
|
|
||||||
if (Ty->isSigned())
|
if (Ty->isSigned())
|
||||||
return ConstantSInt::get(Ty, (int64_t)Val);
|
return ConstantSInt::get(Ty, -1);
|
||||||
else if (Ty->isUnsigned())
|
else if (Ty->isUnsigned()) {
|
||||||
|
// Calculate -1 casted to the right type...
|
||||||
|
unsigned TypeBits = Ty->getPrimitiveSize()*8;
|
||||||
|
uint64_t Val = (uint64_t)-1LL; // All ones
|
||||||
|
Val >>= 64-TypeBits; // Shift out unwanted 1 bits...
|
||||||
return ConstantUInt::get(Ty, Val);
|
return ConstantUInt::get(Ty, Val);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user