Drop bunch of half-working stuff in the ext_weak linkage support.
[oota-llvm.git] / lib / VMCore / ConstantFold.cpp
index 0c5297fccb3b8571f2d8c337bb292654358e4041..ff4d897e54a8b945d1d49ff959a424f49452b943 100644 (file)
@@ -153,26 +153,20 @@ static Constant *FoldBitCast(Constant *V, const Type *DestTy) {
       // Integral -> Integral. This is a no-op because the bit widths must
       // be the same. Consequently, we just fold to V.
       return V;
-    
-    if (DestTy->isFloatingPoint()) {
-      assert((DestTy == Type::DoubleTy || DestTy == Type::FloatTy) && 
-             "Unknown FP type!");
-      return ConstantFP::get(APFloat(CI->getValue()));
-    }
+
+    if (DestTy->isFloatingPoint())
+      return ConstantFP::get(APFloat(CI->getValue(),
+                                     DestTy != Type::PPC_FP128Ty));
+
     // Otherwise, can't fold this (vector?)
     return 0;
   }
-  
+
   // Handle ConstantFP input.
-  if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
+  if (const ConstantFP *FP = dyn_cast<ConstantFP>(V))
     // FP -> Integral.
-    if (DestTy == Type::Int32Ty) {
-      return ConstantInt::get(FP->getValueAPF().bitcastToAPInt());
-    } else {
-      assert(DestTy == Type::Int64Ty && "only support f32/f64 for now!");
-      return ConstantInt::get(FP->getValueAPF().bitcastToAPInt());
-    }
-  }
+    return ConstantInt::get(FP->getValueAPF().bitcastToAPInt());
+
   return 0;
 }
 
@@ -802,16 +796,6 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
         (void)C3V.divide(C2V, APFloat::rmNearestTiesToEven);
         return ConstantFP::get(C3V);
       case Instruction::FRem:
-        if (C2V.isZero()) {
-          // IEEE 754, Section 7.1, #5
-          if (CFP1->getType() == Type::DoubleTy)
-            return ConstantFP::get(APFloat(std::numeric_limits<double>::
-                                           quiet_NaN()));
-          if (CFP1->getType() == Type::FloatTy)
-            return ConstantFP::get(APFloat(std::numeric_limits<float>::
-                                           quiet_NaN()));
-          break;
-        }
         (void)C3V.mod(C2V, APFloat::rmNearestTiesToEven);
         return ConstantFP::get(C3V);
       }