Only do masking for unsigned values!
authorChris Lattner <sabre@nondot.org>
Mon, 6 May 2002 18:54:59 +0000 (18:54 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 6 May 2002 18:54:59 +0000 (18:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2504 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 5b9f31892ea2c31574ab8680392998b87ca9bd84..fda64ab49adf9b7522a7788fd8fbd6efe14c5725 100644 (file)
@@ -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;
 }