Fix some minor issues folding undef, PR2052
authorChris Lattner <sabre@nondot.org>
Tue, 19 Feb 2008 06:22:12 +0000 (06:22 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 19 Feb 2008 06:22:12 +0000 (06:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47314 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstantFold.cpp

index 4983a036be2821bf449edb4c29fc31baf3f90431..06dc9dc89f7986a64cac9208efb7ffd7f680ac91 100644 (file)
@@ -175,7 +175,9 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
   if (isa<UndefValue>(V)) {
     // zext(undef) = 0, because the top bits will be zero.
     // sext(undef) = 0, because the top bits will all be the same.
-    if (opc == Instruction::ZExt || opc == Instruction::SExt)
+    // [us]itofp(undef) = 0, because the result value is bounded.
+    if (opc == Instruction::ZExt || opc == Instruction::SExt ||
+        opc == Instruction::UIToFP || opc == Instruction::SIToFP)
       return Constant::getNullValue(DestTy);
     return UndefValue::get(DestTy);
   }