Demoting CHelpers.h to include/llvm/Support.
[oota-llvm.git] / lib / VMCore / ConstantFold.cpp
index 917098d35137ce93926f5b51182ca762e7702c4e..73ca47a9aa56c565f3e69b5e19d2c698d15fcb10 100644 (file)
@@ -194,11 +194,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
       APFloat V = FPC->getValueAPF();
       uint64_t x[2]; 
       uint32_t DestBitWidth = cast<IntegerType>(DestTy)->getBitWidth();
-      APFloat::opStatus status = V.convertToInteger(x, DestBitWidth, 
-                             opc==Instruction::FPToSI,
-                             APFloat::rmNearestTiesToEven);
-      if (status!=APFloat::opOK && status!=APFloat::opInexact)
-        return 0; // give up
+      (void) V.convertToInteger(x, DestBitWidth, opc==Instruction::FPToSI,
+                                APFloat::rmTowardZero);
       APInt Val(DestBitWidth, 2, x);
       return ConstantInt::get(Val);
     }
@@ -699,23 +696,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
         (void)C3V.multiply(C2V, APFloat::rmNearestTiesToEven);
         return ConstantFP::get(CFP1->getType(), C3V);
       case Instruction::FDiv:
-        // FIXME better to look at the return code
-        if (C2V.isZero())
-          if (C1V.isZero())
-            // IEEE 754, Section 7.1, #4
-            return ConstantFP::get(CFP1->getType(), isDouble ?
-                            APFloat(std::numeric_limits<double>::quiet_NaN()) :
-                            APFloat(std::numeric_limits<float>::quiet_NaN()));
-          else if (C2V.isNegZero() || C1V.isNegative())
-            // IEEE 754, Section 7.2, negative infinity case
-            return ConstantFP::get(CFP1->getType(), isDouble ?
-                            APFloat(-std::numeric_limits<double>::infinity()) :
-                            APFloat(-std::numeric_limits<float>::infinity()));
-          else
-            // IEEE 754, Section 7.2, positive infinity case
-            return ConstantFP::get(CFP1->getType(), isDouble ?
-                            APFloat(std::numeric_limits<double>::infinity()) :
-                            APFloat(std::numeric_limits<float>::infinity()));
         (void)C3V.divide(C2V, APFloat::rmNearestTiesToEven);
         return ConstantFP::get(CFP1->getType(), C3V);
       case Instruction::FRem: