diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-06 18:54:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-06 18:54:59 +0000 |
commit | d661937352ab5c2fb7c43abb75e0452cb7001750 (patch) | |
tree | 75f89f1e54a7b74e1b05799778c8f73c8f88082f | |
parent | 5f06e10a84f7059135a0323d2935d10a83d97907 (diff) | |
download | external_llvm-d661937352ab5c2fb7c43abb75e0452cb7001750.zip external_llvm-d661937352ab5c2fb7c43abb75e0452cb7001750.tar.gz external_llvm-d661937352ab5c2fb7c43abb75e0452cb7001750.tar.bz2 |
Only do masking for unsigned values!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2504 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 5b9f318..fda64ab 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -249,16 +249,15 @@ static Constant *getMaxValue(const Type *Ty) { if (Ty == Type::BoolTy) 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()) - return ConstantSInt::get(Ty, (int64_t)Val); - else if (Ty->isUnsigned()) + return ConstantSInt::get(Ty, -1); + 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 0; } |