[llvm-commits] CVS: llvm/include/llvm/Constants.h

Chris Lattner lattner at cs.uiuc.edu
Mon Feb 2 12:41:04 PST 2004


Changes in directory llvm/include/llvm:

Constants.h updated: 1.39 -> 1.40

---
Log message:

Add a new method to ConstantFP


---
Diffs of the changes:  (+18 -0)

Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.39 llvm/include/llvm/Constants.h:1.40
--- llvm/include/llvm/Constants.h:1.39	Sun Feb  1 16:48:09 2004
+++ llvm/include/llvm/Constants.h	Mon Feb  2 12:40:29 2004
@@ -283,6 +283,24 @@
     return T.I == 0;
   }
 
+  /// isExactlyValue - We don't rely on operator== working on double values, as
+  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
+  /// As such, this method can be used to do an exact bit-for-bit comparison of
+  /// two floating point values.
+  bool isExactlyValue(double V) const {
+    union {
+      double V;
+      uint64_t I;
+    } T1;
+    T1.V = Val;
+    union {
+      double V;
+      uint64_t I;
+    } T2;
+    T2.V = Val;
+    return T1.I == T2.I;
+  }
+
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const ConstantFP *) { return true; }
   static bool classof(const Constant *CPV);  // defined in Constants.cpp





More information about the llvm-commits mailing list