[llvm-commits] [llvm] r49410 - /llvm/trunk/include/llvm/Constants.h

Chris Lattner sabre at nondot.org
Tue Apr 8 17:03:58 PDT 2008


Author: lattner
Date: Tue Apr  8 19:03:58 2008
New Revision: 49410

URL: http://llvm.org/viewvc/llvm-project?rev=49410&view=rev
Log:
make ConstantFP::isExactlyValue work for long double as well.

Modified:
    llvm/trunk/include/llvm/Constants.h

Modified: llvm/trunk/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=49410&r1=49409&r2=49410&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Tue Apr  8 19:03:58 2008
@@ -251,16 +251,13 @@
   /// 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; }





More information about the llvm-commits mailing list