Revert last patch. ConstantInt isn't quite ready for signlessness.
authorReid Spencer <rspencer@reidspencer.com>
Mon, 18 Dec 2006 04:22:56 +0000 (04:22 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 18 Dec 2006 04:22:56 +0000 (04:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32650 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstantFold.cpp

index 32414721a7f2338db9057ac058001b21cde32740..170df73272330a34d597348d7e739fc81578d758 100644 (file)
@@ -875,14 +875,16 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
     // A ZExt always produces an unsigned value so we need to cast the value
     // now before we try to cast it to the destination type
     if (isa<ConstantInt>(V))
-      V = ConstantInt::get(SrcTy, cast<ConstantIntegral>(V)->getZExtValue());
+      V = ConstantInt::get(SrcTy->getUnsignedVersion(), 
+                           cast<ConstantIntegral>(V)->getZExtValue());
     break;
   case Instruction::SIToFP:
   case Instruction::SExt:
     // A SExt always produces a signed value so we need to cast the value
     // now before we try to cast it to the destiniation type.
     if (isa<ConstantInt>(V))
-      V = ConstantInt::get(SrcTy, cast<ConstantIntegral>(V)->getSExtValue());
+      V = ConstantInt::get(SrcTy->getSignedVersion(), 
+                           cast<ConstantIntegral>(V)->getSExtValue());
     else if (const ConstantBool *CB = dyn_cast<ConstantBool>(V))
       V = ConstantInt::get(Type::SByteTy, CB->getValue() ? -1 : 0);