make ConstantFP::isExactlyValue work for long double as well.
authorChris Lattner <sabre@nondot.org>
Wed, 9 Apr 2008 00:03:58 +0000 (00:03 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 9 Apr 2008 00:03:58 +0000 (00:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49410 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h

index 13df601f4187a9237b9e3f766f16a2c5366bf7b8..b7c16e4f8c74007ead943337de0da872fbce16ed 100644 (file)
@@ -251,16 +251,13 @@ public:
   /// As such, this method can be used to do an exact bit-for-bit comparison of
   /// two floating point values.  The version with a double operand is retained
   /// because it's so convenient to write isExactlyValue(2.0), but please use
-  /// it only for constants.
+  /// it only for simple constants.
   bool isExactlyValue(const APFloat& V) const;
 
   bool isExactlyValue(double V) const {
-    if (&Val.getSemantics() == &APFloat::IEEEdouble)
-      return isExactlyValue(APFloat(V));
-    else if (&Val.getSemantics() == &APFloat::IEEEsingle)
-      return isExactlyValue(APFloat((float)V));
-    assert(0);
-    return false;
+    APFloat FV(V);
+    FV.convert(Val.getSemantics(), APFloat::rmNearestTiesToEven);
+    return isExactlyValue(FV);
   }
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantFP *) { return true; }